1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-09-24 13:49:44 +00:00
Files
comunicapiv3/src/api_data/entities_constructor.rs
2020-07-14 10:08:30 +02:00

16 lines
383 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: &Vec<Self::Item>) -> Vec<Self>
where Self: std::marker::Sized {
l.iter().map(Self::new).collect()
}
}