pub struct R11Store<T, U>{
pub left: XvcStore<T>,
pub right: XvcStore<U>,
}
Expand description
Fields§
§left: XvcStore<T>
The first XvcStore to be associated
right: XvcStore<U>
The second XvcStore to be associated
Implementations§
Source§impl<T, U> R11Store<T, U>
impl<T, U> R11Store<T, U>
Sourcepub fn new() -> R11Store<T, U>
pub fn new() -> R11Store<T, U>
Creates an empty R11Store
The following creates two new stores: XvcStore<String>
and XvcStore<i32>
that can be
used in parallel with the same XvcEntity
keys.
use xvc_ecs::R11Store;
let rs = R11Store::<String, i32>::new();
Sourcepub fn insert(
&mut self,
entity: &XvcEntity,
left_component: T,
right_component: U,
)
pub fn insert( &mut self, entity: &XvcEntity, left_component: T, right_component: U, )
inserts an element to both left and right
Having a R11Store<String, String>, the following code inserts “left component” and “right
component” with the same XvcEntity(100)
.
let entity: XvcEntity = 100.into();
rs.insert(&entity, "left component".into(), "right component".into());
Sourcepub fn left_to_right(&self, entity: &XvcEntity) -> Option<(&XvcEntity, &U)>
pub fn left_to_right(&self, entity: &XvcEntity) -> Option<(&XvcEntity, &U)>
returns the right element in L-R pair
let entity: XvcEntity = (100u64, 200u64).into();
rs.insert(&entity, "left component".into(), "right component".to_string());
Sourcepub fn right_to_left(&self, entity: &XvcEntity) -> Option<(&XvcEntity, &T)>
pub fn right_to_left(&self, entity: &XvcEntity) -> Option<(&XvcEntity, &T)>
returns the left element in L-R pair
let entity: XvcEntity = (100, 200).into();
rs.insert(&entity, "left component".into(), "right component".into());
Sourcepub fn tuple(&self, entity: &XvcEntity) -> (Option<&T>, Option<&U>)
pub fn tuple(&self, entity: &XvcEntity) -> (Option<&T>, Option<&U>)
Returns L-R as a tuple
let entity: XvcEntity = (100, 200).into();
rs.insert(&entity, "left component".into(), "right component".into());
let t = rs.tuple(&entity);
Sourcepub fn entity_by_left(&self, left_element: &T) -> Option<XvcEntity>
pub fn entity_by_left(&self, left_element: &T) -> Option<XvcEntity>
Finds the entity from the left value
Sourcepub fn entity_by_right(&self, right_element: &U) -> Option<XvcEntity>
pub fn entity_by_right(&self, right_element: &U) -> Option<XvcEntity>
Finds the first entity from the right value
Sourcepub fn lookup_by_left(&self, left_element: &T) -> Option<&U>
pub fn lookup_by_left(&self, left_element: &T) -> Option<&U>
Search the right value by left
Sourcepub fn lookup_by_right(&self, right_element: &U) -> Option<&T>
pub fn lookup_by_right(&self, right_element: &U) -> Option<&T>
Search the left value by right
Source§impl<T, U> R11Store<T, U>
impl<T, U> R11Store<T, U>
Sourcepub fn load_r11store(store_root: &Path) -> Result<R11Store<T, U>, Error>
pub fn load_r11store(store_root: &Path) -> Result<R11Store<T, U>, Error>
Creates a 1-1 store by loading member stores with XvcStore::load_store
Sourcepub fn save_r11store(&self, store_root: &Path) -> Result<(), Error>
pub fn save_r11store(&self, store_root: &Path) -> Result<(), Error>
Records a store by recording the member stores with XvcStore::save.
Trait Implementations§
Auto Trait Implementations§
impl<T, U> Freeze for R11Store<T, U>
impl<T, U> RefUnwindSafe for R11Store<T, U>where
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for R11Store<T, U>
impl<T, U> Sync for R11Store<T, U>
impl<T, U> Unpin for R11Store<T, U>
impl<T, U> UnwindSafe for R11Store<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> 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