Skip to main content

Doublets

Trait Doublets 

Source
pub trait Doublets<T: LinkReference>: Links<T> {
Show 38 methods // Required method fn get_link(&self, index: T) -> Option<Link<T>>; // Provided methods fn count_by(&self, query: impl ToQuery<T>) -> T where Self: Sized { ... } fn count(&self) -> T where Self: Sized { ... } 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 { ... } fn create_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>> where Self: Sized { ... } fn create_with<F>(&mut self, handler: F) -> Result<Flow, Error<T>> where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized { ... } fn create(&mut self) -> Result<T, Error<T>> where Self: Sized { ... } fn each_by<F>(&self, query: impl ToQuery<T>, handler: F) -> Flow where F: FnMut(Link<T>) -> Flow, Self: Sized { ... } fn each<F>(&self, handler: F) -> Flow where F: FnMut(Link<T>) -> Flow, Self: Sized { ... } 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 { ... } fn update_by( &mut self, query: impl ToQuery<T>, change: impl ToQuery<T>, ) -> Result<T, Error<T>> where Self: Sized { ... } 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 { ... } fn update(&mut self, index: T, source: T, target: T) -> Result<T, Error<T>> where Self: Sized { ... } 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 { ... } fn delete_by(&mut self, query: impl ToQuery<T>) -> Result<T, Error<T>> where Self: Sized { ... } fn delete_with<F>(&mut self, index: T, handler: F) -> Result<Flow, Error<T>> where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized { ... } fn delete(&mut self, index: T) -> Result<T, Error<T>> where Self: Sized { ... } fn try_get_link(&self, index: T) -> Result<Link<T>, Error<T>> { ... } fn delete_all(&mut self) -> Result<(), Error<T>> where Self: Sized { ... } 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 { ... } fn delete_usages_with<F>( &mut self, index: T, handler: F, ) -> Result<(), Error<T>> where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized { ... } fn delete_usages(&mut self, index: T) -> Result<(), Error<T>> where Self: Sized { ... } fn create_point(&mut self) -> Result<T, Error<T>> where Self: Sized { ... } fn create_link_with<F>( &mut self, source: T, target: T, handler: F, ) -> Result<Flow, Error<T>> where F: FnMut(Link<T>, Link<T>) -> Flow, Self: Sized { ... } fn create_link(&mut self, source: T, target: T) -> Result<T, Error<T>> where Self: Sized { ... } fn found(&self, query: impl ToQuery<T>) -> bool where Self: Sized { ... } fn find(&self, query: impl ToQuery<T>) -> Option<Link<T>> where Self: Sized { ... } fn search(&self, source: T, target: T) -> Option<T> where Self: Sized { ... } fn search_or(&self, source: T, target: T, default: T) -> T where Self: Sized { ... } fn single(&self, query: impl ToQuery<T>) -> Option<Link<T>> where Self: Sized { ... } fn get_or_create(&mut self, source: T, target: T) -> Result<T, Error<T>> where Self: Sized { ... } fn count_usages(&self, index: T) -> Result<T, Error<T>> where Self: Sized { ... } fn usages(&self, index: T) -> Result<Vec<T>, Error<T>> where Self: Sized { ... } fn exist(&self, link: T) -> bool where Self: Sized { ... } fn has_usages(&self, link: T) -> bool where Self: Sized { ... } 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 { ... } fn rebase(&mut self, old: T, new: T) -> Result<T, Error<T>> where Self: Sized { ... } fn rebase_and_delete(&mut self, old: T, new: T) -> Result<T, Error<T>> where Self: Sized { ... }
}
Expand description

High-level API for a doublets link store, extending Links with ergonomic helpers.

All methods have default implementations built on top of Links.

Required Methods§

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

Provided Methods§

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. Duplicate matches are deleted once, in reverse order of their first occurrence.

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 each other link that uses index as a source or target once, calling handler for each deletion.

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 distinct 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 distinct other 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.

A usage that references old as both source and target is updated once, replacing both references together. The link at old itself is excluded.

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: LinkReference, All: Doublets<T> + ?Sized> Doublets<T> for Box<All>

Implementors§

Source§

impl<T: LinkReference, L: Doublets<T>, J: TransitionLog<T>> Doublets<T> for Transaction<'_, T, L, J>

Source§

impl<T: LinkReference, L: Doublets<T>, J: TransitionLog<T>> Doublets<T> for TransactionsDecorator<T, L, J>

Source§

impl<T: LinkReference, L: Doublets<T>, W: Write + Send + Sync> Doublets<T> for LoggingDecorator<T, L, W>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for CascadeUniquenessAndUsagesResolver<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for CascadeUsagesResolver<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for InnerReferenceExistenceValidator<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for ItselfConstantToSelfReferenceResolver<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for NoExceptionsDecorator<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for NonExistentDependenciesCreator<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for NonNullContentsLinkDeletionResolver<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for NullConstantToSelfReferenceResolver<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for UniquenessResolver<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for UniquenessValidator<T, L>

Source§

impl<T: LinkReference, L: Doublets<T>> Doublets<T> for UsagesValidator<T, L>

Source§

impl<T: LinkReference, M: RawMem<Item = LinkPart<T>>, TS: UnitTree<T>, TT: UnitTree<T>, TU: UnitList<T>> Doublets<T> for doublets::mem::unit::Store<T, M, TS, TT, TU>

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 doublets::mem::split::Store<T, MD, MI, IS, ES, IT, ET, UL>