pub struct R1NStore<T, U>{
pub parents: XvcStore<T>,
pub children: XvcStore<U>,
pub child_parents: XvcStore<ChildEntity<U, T>>,
}
Expand description
RNStore is 1-N RelationStore, where we store one-to-many relationships between two entities. It doesn’t have any semantics except binding two entities together.
Fields§
§parents: XvcStore<T>
Keeps the parent type
children: XvcStore<U>
Keeps the child type
child_parents: XvcStore<ChildEntity<U, T>>
Keeps the relationships between child entities and parent entities The key for the child_parents is the child entity, as there are many children for a parent.
Implementations§
Source§impl<T, U> R1NStore<T, U>
impl<T, U> R1NStore<T, U>
Sourcepub fn insert(
&mut self,
parent_entity: XvcEntity,
parent_component: T,
child_entity: XvcEntity,
child_component: U,
) -> Option<XvcEntity>
pub fn insert( &mut self, parent_entity: XvcEntity, parent_component: T, child_entity: XvcEntity, child_component: U, ) -> Option<XvcEntity>
Insert a child component to a parent parent_component. It checks whether the parent is equal to the given, and updates if there is a change.
Sourcepub fn children_of(&self, parent_entity: &XvcEntity) -> Result<HStore<U>>
pub fn children_of(&self, parent_entity: &XvcEntity) -> Result<HStore<U>>
get the store of related entities.
Sourcepub fn parent_of(
&self,
child_entity: &XvcEntity,
) -> Result<(&ChildEntity<U, T>, &T)>
pub fn parent_of( &self, child_entity: &XvcEntity, ) -> Result<(&ChildEntity<U, T>, &T)>
Get left entity that’s related with thethe right child_entity
.
Sourcepub fn remove_child(&mut self, child_entity: XvcEntity) -> Result<()>
pub fn remove_child(&mut self, child_entity: XvcEntity) -> Result<()>
Remove the child entity from child-parent store and children store
Source§impl<T, U> R1NStore<T, U>
impl<T, U> R1NStore<T, U>
Sourcepub fn load_r1nstore(store_root: &Path) -> Result<R1NStore<T, U>>
pub fn load_r1nstore(store_root: &Path) -> Result<R1NStore<T, U>>
Loads the stores from store root and directory named after type names
Sourcepub fn save_r1nstore(store: &Self, store_root: &Path) -> Result<()>
pub fn save_r1nstore(store: &Self, store_root: &Path) -> Result<()>
Records the stores to store root and directories created from type names
Trait Implementations§
Auto Trait Implementations§
impl<T, U> Freeze for R1NStore<T, U>
impl<T, U> RefUnwindSafe for R1NStore<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for R1NStore<T, U>
impl<T, U> Sync for R1NStore<T, U>
impl<T, U> Unpin for R1NStore<T, U>
impl<T, U> UnwindSafe for R1NStore<T, U>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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