Skip to main content

Preloadable

Trait Preloadable 

Source
pub trait Preloadable:
    Sized
    + Send
    + Sync
    + 'static {
    type Spec: Default + Send + Sync + 'static;

    // Required method
    fn load_associations<'a>(
        records: &'a mut [Preloaded<Self>],
        spec: &'a Self::Spec,
        conn: &'a mut RuntimeConnection,
    ) -> PreloadFuture<'a>;
}
Expand description

Implemented by every #[model] to drive batched eager loading.

#[model] generates the implementation; you rarely implement this by hand. A manual implementation is only needed for hand-written models that appear as the target of an association declared elsewhere (so they can be wrapped in Preloaded and, optionally, nested into).

Required Associated Types§

Source

type Spec: Default + Send + Sync + 'static

The builder describing which associations (and nested associations) to load. #[model] generates a {Model}Preload type; association-free models use super::NoPreload.

Required Methods§

Source

fn load_associations<'a>( records: &'a mut [Preloaded<Self>], spec: &'a Self::Spec, conn: &'a mut RuntimeConnection, ) -> PreloadFuture<'a>

Load every association named in spec for records, issuing at most one batched query per association level, then recurse into any nested specs. All queries run on conn so preloads share the read role of the parent query.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§