pub enum Relation {
BelongsTo {
local_type: &'static str,
foreign_type: &'static str,
fk_field_json: &'static str,
extract_fk: FkExtractor,
exclude_from_tree: bool,
},
OwnsMany {
local_type: &'static str,
foreign_type: &'static str,
extract_ids: ArrayExtractor,
remove_id: ArrayRemover,
exclude_from_tree: bool,
},
EnsureFor {
local_type: &'static str,
dependencies: &'static [EnsureForDependency],
make_entity: EntityFactory,
exclude_from_tree: bool,
},
}Expand description
Represents the different types of entity relationships
Variants§
BelongsTo
Child entity has a foreign key pointing to parent. When parent is DEL’d -> cascade delete all children with matching FK.
Example: Binding.scope_id belongs to Scene.id
When Scene is deleted, all Bindings with that scope_id are deleted.
Fields
extract_fk: FkExtractorFunction to extract the FK value from a child entity
OwnsMany
Parent entity owns an array of child IDs. When parent DEL’d -> cascade delete all referenced children. When child DEL’d -> remove child ID from parent’s array, recalculate hash.
Example: Scene.node_ids owns BindingNode entities
When Scene is deleted, all BindingNodes in node_ids are deleted.
When a BindingNode is deleted, it’s removed from the owning Scene’s node_ids.
Fields
extract_ids: ArrayExtractorFunction to extract owned IDs from a parent entity
remove_id: ArrayRemoverFunction to remove an ID from parent and return updated entity as Value
EnsureFor
Auto-create entity for each combination of dependencies. When any dependency is SET -> ensure local entity exists for all combinations.
Example: BundleStatus ensure-for (Session, Bundle)
Creates one BundleStatus per Session×Bundle combination.
Fields
dependencies: &'static [EnsureForDependency]Dependencies to create Cartesian product from
make_entity: EntityFactoryFactory function to create entity with dependency IDs populated. Takes slice of dependency IDs in same order as dependencies array. Returns complete entity with id, hash, FK fields, and default values.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Relation
impl RefUnwindSafe for Relation
impl Send for Relation
impl Sync for Relation
impl Unpin for Relation
impl UnsafeUnpin for Relation
impl UnwindSafe for Relation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more