Struct R11Store

Source
pub struct R11Store<T, U>
where T: Storable, U: Storable,
{ pub left: XvcStore<T>, pub right: XvcStore<U>, }
Expand description

Associates two XvcStores with two different type of components with a single XvcEntity. It’s like using the same primary key in two database tables.

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>
where T: Storable, U: Storable,

Source

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();
Source

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());
Source

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());
Source

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());
Source

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);
Source

pub fn entity_by_left(&self, left_element: &T) -> Option<XvcEntity>

Finds the entity from the left value

Source

pub fn entity_by_right(&self, right_element: &U) -> Option<XvcEntity>

Finds the first entity from the right value

Source

pub fn remove(&mut self, entity: XvcEntity)

removes the components from both right and left

Source

pub fn lookup_by_left(&self, left_element: &T) -> Option<&U>

Search the right value by left

Source

pub fn lookup_by_right(&self, right_element: &U) -> Option<&T>

Search the left value by right

Source

pub fn filter(&self, predicate: impl Fn(&T, &U) -> bool) -> R11Store<T, U>

Run a filter on the store and return elements selected by the predicate

Source§

impl<T, U> R11Store<T, U>
where T: Storable, U: Storable,

Source

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

Source

pub fn save_r11store(&self, store_root: &Path) -> Result<(), Error>

Records a store by recording the member stores with XvcStore::save.

Trait Implementations§

Source§

impl<T, U> Clone for R11Store<T, U>
where T: Clone + Storable, U: Clone + Storable,

Source§

fn clone(&self) -> R11Store<T, U>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, U> Debug for R11Store<T, U>
where T: Debug + Storable, U: Debug + Storable,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T, U> Default for R11Store<T, U>
where T: Storable, U: Storable,

Source§

fn default() -> R11Store<T, U>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, U> Freeze for R11Store<T, U>

§

impl<T, U> RefUnwindSafe for R11Store<T, U>

§

impl<T, U> Send for R11Store<T, U>
where T: Send, U: Send,

§

impl<T, U> Sync for R11Store<T, U>
where T: Sync, U: Sync,

§

impl<T, U> Unpin for R11Store<T, U>
where T: Unpin, U: Unpin,

§

impl<T, U> UnwindSafe for R11Store<T, U>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T