pub(crate) trait ContentEntity:
Clone
+ PartialEq
+ Into<EntitySnapshot> {
const ENTITY_TYPE: ContentEntityType;
// Required methods
fn id(&self) -> Uuid;
fn course_id(&self) -> Uuid;
fn label(&self) -> &str;
fn narrow(snapshot: &EntitySnapshot) -> Option<&Self>;
async fn load_live(
conn: &mut PgConnection,
ids: &[Uuid],
) -> ModelResult<HashMap<Uuid, Self>>;
async fn lock_rows(conn: &mut PgConnection, ids: &[Uuid]) -> ModelResult<()>;
// Provided method
fn parent(&self) -> Option<EntityKey> { ... }
}Expand description
What models know about one kind of content entity, implemented by its snapshot type, so that
code over every kind dispatches on ContentEntityType once.
Required Associated Constants§
Required Methods§
fn course_id(&self) -> Uuid
Sourcefn label(&self) -> &str
fn label(&self) -> &str
See EntityRef::label.
Sourcefn narrow(snapshot: &EntitySnapshot) -> Option<&Self>
fn narrow(snapshot: &EntitySnapshot) -> Option<&Self>
The snapshot, if it is of this kind.
Sourceasync fn load_live(
conn: &mut PgConnection,
ids: &[Uuid],
) -> ModelResult<HashMap<Uuid, Self>>
async fn load_live( conn: &mut PgConnection, ids: &[Uuid], ) -> ModelResult<HashMap<Uuid, Self>>
The live entities with the ids, as load_live_many has them, by id.
Sourceasync fn lock_rows(conn: &mut PgConnection, ids: &[Uuid]) -> ModelResult<()>
async fn lock_rows(conn: &mut PgConnection, ids: &[Uuid]) -> ModelResult<()>
Locks the entities’ rows until the transaction ends. Soft-deleted rows are locked too: a
publish can restore them. ids must be sorted, so that concurrent lockers take the rows in
the same order.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.