Skip to main content

Store

Struct Store 

Source
pub struct Store<T: LinkReference, MD: RawMem<Item = DataPart<T>>, MI: RawMem<Item = IndexPart<T>>, IS: SplitTree<T> = InternalSourcesRecursionlessTree<T>, ES: SplitTree<T> = ExternalSourcesRecursionlessTree<T>, IT: SplitTree<T> = InternalTargetsRecursionlessTree<T>, ET: SplitTree<T> = ExternalTargetsRecursionlessTree<T>, UL: SplitList<T> = UnusedLinks<T>> {
    pub external_sources: ES,
    pub external_targets: ET,
    /* private fields */
}
Expand description

A split-memory doublets store that keeps link data and index metadata in separate regions.

MD holds the raw (source, target) data; MI holds the tree-index structures. Use Store::new for default constants or Store::with_constants for custom ones.

Fields§

§external_sources: ES§external_targets: ET

Implementations§

Source§

impl<T: LinkReference, MD: RawMem<Item = DataPart<T>>, MI: RawMem<Item = IndexPart<T>>, IS: SplitTree<T>, ES: SplitTree<T>, IT: SplitTree<T>, ET: SplitTree<T>, UL: SplitList<T>> Store<T, MD, MI, IS, ES, IT, ET, UL>

Source

pub fn with_constants( data_mem: MD, index_mem: MI, constants: LinksConstants<T>, ) -> Result<Store<T, MD, MI>, LinksError<T>>

Creates a split store with the given data memory, index memory, and constants.

Source

pub fn new( data_mem: MD, index_mem: MI, ) -> Result<Store<T, MD, MI>, LinksError<T>>

Creates a split store using the given memories and default LinksConstants.

Source

pub fn get_data_part(&self, index: T) -> &DataPart<T>

Returns the raw data part (source/target) for the link at index.

Source

pub fn get_index_part(&self, index: T) -> &IndexPart<T>

Returns the raw index part (tree metadata) for the link at index.

Source

pub fn is_unused(&self, link: T) -> bool

Returns true if the slot at link is in the free-list (deleted but not yet reused).

Source

pub fn is_virtual(&self, link: T) -> bool

Returns true if link is a virtual (external/unused) reference.

Source

pub fn exists(&self, link: T) -> bool

Returns true if link is an allocated, non-deleted internal link.

Trait Implementations§

Source§

impl<T: LinkReference, MD: RawMem<Item = DataPart<T>>, MI: RawMem<Item = IndexPart<T>>, IS: SplitTree<T>, ES: SplitTree<T>, IT: SplitTree<T>, ET: SplitTree<T>, UL: SplitList<T>> Doublets<T> for Store<T, MD, MI, IS, ES, IT, ET, UL>

Returns the link at index, or None if it does not exist.
Source§

fn count_by(&self, query: impl ToQuery<T>) -> T
where Self: Sized,

Counts links matching query.
Source§

fn count(&self) -> T
where Self: Sized,

Returns the total number of links in the store.
Source§

fn create_by_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<Flow, Error<T>>
where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Creates a link matching query, calling handler on each created link.
Source§

fn create_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>
where Self: Sized,

Creates a link matching query and returns its index.
Source§

fn create_with<F>(&mut self, handler: F) -> Result<Flow, Error<T>>
where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Creates a new link and calls handler with the before/after states.
Source§

fn create(&mut self) -> Result<T, Error<T>>
where Self: Sized,

Creates a new uninitialized link and returns its index.
Source§

fn each_by<F>(&self, query: impl ToQuery<T>, handler: F) -> Flow
where F: FnMut(Link<T>) -> Flow, Self: Sized,

Iterates over links matching query, calling handler for each.
Source§

fn each<F>(&self, handler: F) -> Flow
where F: FnMut(Link<T>) -> Flow, Self: Sized,

Iterates over all links in the store, calling handler for each.
Source§

fn update_by_with<H>( &mut self, query: impl ToQuery<T>, change: impl ToQuery<T>, handler: H, ) -> Result<Flow, Error<T>>
where H: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Updates links matching query to change, calling handler with before/after.
Source§

fn update_by( &mut self, query: impl ToQuery<T>, change: impl ToQuery<T>, ) -> Result<T, Error<T>>
where Self: Sized,

Updates links matching query to change and returns the updated link’s index.
Source§

fn update_with<F>( &mut self, index: T, source: T, target: T, handler: F, ) -> Result<Flow, Error<T>>
where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Updates the link at index to (index, source, target), calling handler.
Source§

fn update(&mut self, index: T, source: T, target: T) -> Result<T, Error<T>>
where Self: Sized,

Updates the link at index to (index, source, target) and returns the index.
Source§

fn delete_by_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<Flow, Error<T>>
where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Deletes links matching query, calling handler with before/after states.
Source§

fn delete_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>>
where Self: Sized,

Deletes links matching query and returns the deleted link’s index.
Source§

fn delete_with<F>(&mut self, index: T, handler: F) -> Result<Flow, Error<T>>
where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Deletes the link at index, calling handler with before/after states.
Source§

fn delete(&mut self, index: T) -> Result<T, Error<T>>
where Self: Sized,

Deletes the link at index and returns its former index.
Returns the link at index, or Err(Error::NotExists) if it does not exist.
Source§

fn delete_all(&mut self) -> Result<(), Error<T>>
where Self: Sized,

Deletes all links in the store.
Source§

fn delete_query_with<F>( &mut self, query: impl ToQuery<T>, handler: F, ) -> Result<(), Error<T>>
where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Deletes all links matching query, calling handler for each deletion.
Source§

fn delete_usages_with<F>( &mut self, index: T, handler: F, ) -> Result<(), Error<T>>
where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Deletes all links that use index as a source or target, calling handler for each.
Source§

fn delete_usages(&mut self, index: T) -> Result<(), Error<T>>
where Self: Sized,

Deletes all links that use index as a source or target.
Source§

fn create_point(&mut self) -> Result<T, Error<T>>
where Self: Sized,

Creates a self-referential point link and returns its index.
Creates a link from source to target, calling handler with before/after states.
Creates a link from source to target and returns its index.
Source§

fn found(&self, query: impl ToQuery<T>) -> bool
where Self: Sized,

Returns true if at least one link matches query.
Source§

fn find(&self, query: impl ToQuery<T>) -> Option<Link<T>>
where Self: Sized,

Returns the first link matching query, or None.
Source§

fn search(&self, source: T, target: T) -> Option<T>
where Self: Sized,

Returns the index of a link with the given source and target, or None.
Source§

fn search_or(&self, source: T, target: T, default: T) -> T
where Self: Sized,

👎Deprecated:

use search instead

Source§

fn single(&self, query: impl ToQuery<T>) -> Option<Link<T>>
where Self: Sized,

Returns the link matching query only if exactly one link matches; None otherwise.
Source§

fn get_or_create(&mut self, source: T, target: T) -> Result<T, Error<T>>
where Self: Sized,

Returns the index of the (source, target) link, creating it if it does not exist.
Source§

fn count_usages(&self, index: T) -> Result<T, Error<T>>
where Self: Sized,

Returns the number of other links that reference index as a source or target.
Source§

fn usages(&self, index: T) -> Result<Vec<T>, Error<T>>
where Self: Sized,

Returns the indices of all links that reference index as a source or target.
Source§

fn exist(&self, link: T) -> bool
where Self: Sized,

Returns true if the link at link exists (internal or external).
Source§

fn has_usages(&self, link: T) -> bool
where Self: Sized,

Returns true if any other link references link as a source or target.
Source§

fn rebase_with<F>(&mut self, old: T, new: T, handler: F) -> Result<(), Error<T>>
where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized,

Re-points all usages of old to new, calling handler for each update.
Source§

fn rebase(&mut self, old: T, new: T) -> Result<T, Error<T>>
where Self: Sized,

Re-points all usages of old to new and returns new.
Source§

fn rebase_and_delete(&mut self, old: T, new: T) -> Result<T, Error<T>>
where Self: Sized,

Re-points all usages of old to new, then deletes old. Returns new.
Source§

impl<T: LinkReference, MD: RawMem<Item = DataPart<T>>, MI: RawMem<Item = IndexPart<T>>, IS: SplitTree<T>, ES: SplitTree<T>, IT: SplitTree<T>, ET: SplitTree<T>, UL: SplitList<T>> Links<T> for Store<T, MD, MI, IS, ES, IT, ET, UL>

Source§

fn constants(&self) -> &LinksConstants<T>

Returns the store’s LinksConstants (any/null/range values).
Counts links that match query.
Creates one or more links matching query and reports each creation via handler.
Iterates over links matching query, calling handler for each.
Updates links matching query to the new values in change, reporting via handler.
Deletes links matching query and reports each deletion via handler.
Source§

impl<T: LinkReference, MD: RawMem<Item = DataPart<T>>, MI: RawMem<Item = IndexPart<T>>, IS: SplitTree<T>, ES: SplitTree<T>, IT: SplitTree<T>, ET: SplitTree<T>, UL: SplitList<T>> Send for Store<T, MD, MI, IS, ES, IT, ET, UL>

Source§

impl<T: LinkReference, MD: RawMem<Item = DataPart<T>>, MI: RawMem<Item = IndexPart<T>>, IS: SplitTree<T>, ES: SplitTree<T>, IT: SplitTree<T>, ET: SplitTree<T>, UL: SplitList<T>> Sync for Store<T, MD, MI, IS, ES, IT, ET, UL>

Auto Trait Implementations§

§

impl<T, MD, MI, IS, ES, IT, ET, UL> Freeze for Store<T, MD, MI, IS, ES, IT, ET, UL>

§

impl<T, MD, MI, IS, ES, IT, ET, UL> RefUnwindSafe for Store<T, MD, MI, IS, ES, IT, ET, UL>

§

impl<T, MD, MI, IS, ES, IT, ET, UL> Unpin for Store<T, MD, MI, IS, ES, IT, ET, UL>

§

impl<T, MD, MI, IS, ES, IT, ET, UL> UnsafeUnpin for Store<T, MD, MI, IS, ES, IT, ET, UL>

§

impl<T, MD, MI, IS, ES, IT, ET, UL> UnwindSafe for Store<T, MD, MI, IS, ES, IT, ET, UL>

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, L> DecoratorsExt<T> for L
where T: LinkReference, L: Doublets<T>,

Source§

fn with_uniqueness<P: UniquenessPolicy>( self, _policy: P, ) -> P::Decorator<T, Self>

Source§

fn with_usages<P: UsagesPolicy>(self, _policy: P) -> P::Decorator<T, Self>

Source§

fn with_usages_validation(self) -> UsagesValidator<T, Self>

Wraps in UsagesValidator.
Source§

fn with_cascade_usages_resolution(self) -> CascadeUsagesResolver<T, Self>

Source§

fn with_inner_reference_existence_validation( self, ) -> InnerReferenceExistenceValidator<T, Self>

Source§

fn with_non_existent_dependencies_creation( self, ) -> NonExistentDependenciesCreator<T, Self>

Source§

fn with_itself_constant_resolution( self, ) -> ItselfConstantToSelfReferenceResolver<T, Self>

Source§

fn with_null_constant_resolution( self, ) -> NullConstantToSelfReferenceResolver<T, Self>

Source§

fn with_non_null_contents_deletion_resolution( self, ) -> NonNullContentsLinkDeletionResolver<T, Self>

Source§

fn with_logging<W: Write + Send + Sync>( self, writer: W, ) -> LoggingDecorator<T, Self, W>

Wraps in LoggingDecorator, logging every mutation to writer.
Source§

fn with_no_exceptions(self) -> NoExceptionsDecorator<T, Self>

Source§

fn with_automatic_uniqueness_and_usages_resolution( self, ) -> AutomaticUniquenessAndUsagesResolution<T, Self>

Builds the same stack as C# ILinksExtensions.DecorateWithAutomaticUniquenessAndUsagesResolution: CascadeUsagesResolver innermost, then NonNullContentsLinkDeletionResolver, then CascadeUniquenessAndUsagesResolver outermost.
Source§

impl<T, All> DoubletsExt<T> for All
where T: LinkReference, All: Doublets<T>,

Source§

fn iter( &self, ) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator

Returns an iterator over all links in the store.
Source§

fn each_iter( &self, query: impl ToQuery<T>, ) -> impl Iterator<Item = Link<T>> + ExactSizeIterator + DoubleEndedIterator

Returns an iterator over links matching query.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.