pub trait MorphTarget: Sized + Send {
// Required methods
fn morph_types() -> Vec<&'static str>;
fn load_type<'a, Db: ConnectionTrait>(
db: &'a Db,
morph_type: &'a str,
keys: Vec<Key>,
) -> impl Future<Output = Result<Vec<(Key, Self)>, DbErr>> + Send + 'a;
}Expand description
The possible owners of a polymorphic child, as one enum.
A comment’s owner may be a post or a video, so the result is an enum with one
variant per owner entity. Declare it with morph_target!, which
writes this impl for you.
Required Methods§
Sourcefn morph_types() -> Vec<&'static str>
fn morph_types() -> Vec<&'static str>
The morph types this enum covers.
Sourcefn load_type<'a, Db: ConnectionTrait>(
db: &'a Db,
morph_type: &'a str,
keys: Vec<Key>,
) -> impl Future<Output = Result<Vec<(Key, Self)>, DbErr>> + Send + 'a
fn load_type<'a, Db: ConnectionTrait>( db: &'a Db, morph_type: &'a str, keys: Vec<Key>, ) -> impl Future<Output = Result<Vec<(Key, Self)>, DbErr>> + Send + 'a
Loads the owners of one morph type by key, in one query.
§Errors
On a database error, or when morph_type is not one of Self::morph_types.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".