1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-04-30 00:00:53 +00:00
comunicapiv3/src/api_data/entities_constructor.rs

16 lines
380 B
Rust

//! # Entities constructor
//!
//! This trait simplify the construction of new items
pub trait EntitiesConstructor {
type Item;
/// Turn a server item into an API entry
fn new(i: &Self::Item) -> Self;
/// Parse a list of it
fn for_list(l: &[Self::Item]) -> Vec<Self>
where Self: std::marker::Sized {
l.iter().map(Self::new).collect()
}
}