Trait ensemble::Collection

source ·
pub trait Collection {
    // Required methods
    fn load<T>(
        &mut self,
        relation: T
    ) -> impl Future<Output = Result<(), Error>> + Send
       where T: Into<EagerLoad> + Send + Sync + Clone;
    fn json(&self) -> Value;
}

Required Methods§

source

fn load<T>( &mut self, relation: T ) -> impl Future<Output = Result<(), Error>> + Send
where T: Into<EagerLoad> + Send + Sync + Clone,

Eager load a relationship for a collection of models.

Errors

Returns an error if any of the models fail to load, or if a connection to the database cannot be established.

source

fn json(&self) -> Value

Convert the collection to a JSON value.

Panics

Panics if the collection cannot be converted to JSON. Since models manually implement Serialize, this should never happen.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: Model> Collection for &mut Vec<T>

source§

async fn load<U>(&mut self, relation: U) -> Result<(), Error>
where U: Into<EagerLoad> + Send + Sync + Clone,

source§

fn json(&self) -> Value

Implementors§