1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-09-25 06:09:44 +00:00

Create a new trait

This commit is contained in:
2020-07-14 10:08:30 +02:00
parent 161e969966
commit bb86830db4
4 changed files with 24 additions and 7 deletions

View File

@@ -0,0 +1,16 @@
//! # 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()
}
}