Skip to main content

CountedWeave

Struct CountedWeave 

Source
pub struct CountedWeave<W, K, N, T>
where W: Weave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,
{ pub weave: W, pub count: WeaveActionCount, /* private fields */ }
Expand description

A Weave wrapper which logs the number of actions successfully performed on the inner Weave.

See WeaveActionCount for the complete list of loggable actions.

Fields§

§weave: W

The Weave being wrapped.

Actions performed directly on the inner Weave (without using the wrapper’s functions) are not logged.

§count: WeaveActionCount

The number of actions that were performed on the attached Weave.

Implementations§

Source§

impl<W, K, N, T> CountedWeave<W, K, N, T>
where W: Weave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source

pub const fn new(weave: W, count: WeaveActionCount) -> Self

Creates a CountedWeave from a Weave and WeaveActionCount pair.

Source

pub fn from_weave(weave: W) -> Self

Creates a CountedWeave from a Weave.

Source

pub fn into_weave(self) -> W

Converts a CountedWeave into it’s inner Weave.

Source

pub const fn as_weave(&self) -> &W

Returns a reference to the inner Weave.

Source

pub const fn as_count(&self) -> &WeaveActionCount

Returns a reference to the inner WeaveActionCount.

Source

pub fn reset_count(&mut self)

Resets the inner WeaveActionCount to zero.

Trait Implementations§

Source§

impl<W, K, N, T> ActivePathWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: ActivePathWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

type Active = <W as ActivePathWeave<K, N, T>>::Active

Identifiers of active nodes.
Source§

fn active(&self) -> &Self::Active

Returns a reference to the identifiers of active nodes.
Source§

fn set_active_path(&mut self, active: impl Iterator<Item = K>)

Replaces the currently active path with the specified set of node IDs. Read more
Source§

impl<W, K, N, T> ActiveSingularWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: ActiveSingularWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

fn active(&self) -> Option<K>

Returns the active node’s identifier, if any.
Source§

impl<W, K, N, T> Archive for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Archive, K: Hash + Copy + Eq + Ord, N: Node<K, T>, WeaveActionCount: Archive, PhantomData<K>: Archive, PhantomData<N>: Archive, PhantomData<T>: Archive,

Source§

type Archived = ArchivedCountedWeave<W, K, N, T>

The archived representation of this type. Read more
Source§

type Resolver = CountedWeaveResolver<W, K, N, T>

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
Source§

fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)

Creates the archived version of this value at the given position and writes it to the given output. Read more
Source§

const COPY_OPTIMIZATION: CopyOptimization<Self> = _

An optimization flag that allows the bytes of this type to be copied directly to a writer instead of calling serialize. Read more
Source§

impl<W, K, N, T> AsRef<W> for CountedWeave<W, K, N, T>
where W: Weave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

fn as_ref(&self) -> &W

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<W, K, N, T> BookmarkableWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: BookmarkableWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

type Bookmarks = <W as BookmarkableWeave<K, N, T>>::Bookmarks

Identifiers of bookmarked nodes.
Source§

fn bookmarks(&self) -> &Self::Bookmarks

Returns a reference to the identifiers of bookmarked nodes.
Source§

fn contains_bookmark(&self, id: &K) -> bool

Returns true if the Weave contains a bookmarked node with the specified identifier.
Source§

fn set_node_bookmarked_status(&mut self, id: &K, value: bool) -> bool

Sets the bookmarked status of a node with the specified identifier.
Source§

impl<W, K, N, T: Clone> Clone for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Clone, K: Hash + Copy + Eq + Ord + Clone, N: Node<K, T> + Clone,

Source§

fn clone(&self) -> CountedWeave<W, K, N, T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<W, K, N, T: Copy> Copy for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Copy, K: Hash + Copy + Eq + Ord + Copy, N: Node<K, T> + Copy,

Source§

impl<W, K, N, T: Debug> Debug for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Debug, K: Hash + Copy + Eq + Ord + Debug, N: Node<K, T> + Debug,

Source§

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

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

impl<W, K, N, T> DeduplicatableWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: DeduplicatableWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>, T: DeduplicatableContents,

Source§

fn find_duplicates(&self, id: &K) -> impl Iterator<Item = K>

An iterator over the specified node’s sibling identifiers which contain contents which are duplicates of the specified node’s contents.
Source§

impl<W, K, N, T: Default> Default for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Default, K: Hash + Copy + Eq + Ord + Default, N: Node<K, T> + Default,

Source§

fn default() -> CountedWeave<W, K, N, T>

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

impl<__D: Fallible + ?Sized, W, K, N, T> Deserialize<CountedWeave<W, K, N, T>, __D> for Archived<CountedWeave<W, K, N, T>>

Source§

fn deserialize( &self, deserializer: &mut __D, ) -> Result<CountedWeave<W, K, N, T>, <__D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<W, K, N, T> DiscreteWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: DiscreteWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>, T: DiscreteContents,

Source§

fn split_node(&mut self, id: &K, at: usize, new_id: K) -> bool

Splits a node with the specified identifier at the given index, creating a new child node with the identifier new_id. Read more
Source§

fn merge_with_parent(&mut self, id: &K) -> Option<K>

Merges a node with the specified identifier with its parent, with the newly merged node inheriting the parent’s identifier. Read more
Source§

impl<W, K, N, T: Eq> Eq for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Eq, K: Hash + Copy + Eq + Ord + Eq, N: Node<K, T> + Eq,

Source§

impl<W, K, N, T> From<W> for CountedWeave<W, K, N, T>
where W: Weave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

fn from(value: W) -> Self

Converts to this type from the input type.
Source§

impl<W, K, N, T: Hash> Hash for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Hash, K: Hash + Copy + Eq + Ord + Hash, N: Node<K, T> + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<W, K, N, T> IndependentWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: IndependentWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>, T: IndependentContents,

Source§

fn move_node(&mut self, id: &K, new_parents: &[K]) -> bool

Moves a node with the specified identifier to a new set of parent nodes, returning true if the move was successful. Read more
Source§

impl<W, K, N, T, M> MetadataWeave<K, N, T, M> for CountedWeave<W, K, N, T>
where W: MetadataWeave<K, N, T, M>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

fn metadata(&self) -> &M

Returns a reference to the Weave’s associated metadata.
Source§

fn metadata_mut<O>(&mut self, callback: impl FnOnce(&mut M) -> O) -> O

Mutable access to the Weave’s associated metadata. Read more
Source§

impl<W, K, N, T: Ord> Ord for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Ord, K: Hash + Copy + Eq + Ord + Ord, N: Node<K, T> + Ord,

Source§

fn cmp(&self, other: &CountedWeave<W, K, N, T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<W, K, N, T: PartialEq> PartialEq for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + PartialEq, K: Hash + Copy + Eq + Ord + PartialEq, N: Node<K, T> + PartialEq,

Source§

fn eq(&self, other: &CountedWeave<W, K, N, T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<W, K, N, T: PartialOrd> PartialOrd for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + PartialOrd, K: Hash + Copy + Eq + Ord + PartialOrd, N: Node<K, T> + PartialOrd,

Source§

fn partial_cmp(&self, other: &CountedWeave<W, K, N, T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<W, K, N, T> SemiIndependentWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: SemiIndependentWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>, T: IndependentContents,

Source§

fn get_contents_mut<O>( &mut self, id: &K, callback: impl FnOnce(&mut T) -> O, ) -> Option<O>

Mutable access to the contents of a node with the specified identifier. Read more
Source§

impl<__S: Fallible + ?Sized, W, K, N, T> Serialize<__S> for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + Serialize<__S>, K: Hash + Copy + Eq + Ord, N: Node<K, T>, WeaveActionCount: Serialize<__S>, PhantomData<K>: Serialize<__S>, PhantomData<N>: Serialize<__S>, PhantomData<T>: Serialize<__S>,

Source§

fn serialize( &self, serializer: &mut __S, ) -> Result<<Self as Archive>::Resolver, <__S as Fallible>::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
Source§

impl<W, K, N, T> SortableBookmarkableWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: SortableBookmarkableWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

fn sort_bookmarks_by(&mut self, cmp: impl FnMut(&N, &N) -> Ordering)

Sorts bookmarked nodes using the comparison function cmp. Read more
Source§

fn sort_bookmarks_by_id(&mut self, cmp: impl FnMut(&K, &K) -> Ordering)

Sorts the identifiers of bookmarked nodes using the comparison function cmp. Read more
Source§

impl<W, K, N, T> SortableWeave<K, N, T> for CountedWeave<W, K, N, T>
where W: SortableWeave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

fn get_ordered_node_identifiers_mirrored(&mut self, output: &mut Vec<K>)

Builds a list of all node identifiers ordered by their positions in the Weave. Read more
Source§

fn get_ordered_node_identifiers_mirrored_from( &mut self, id: &K, output: &mut Vec<K>, )

Recursively builds a list of all children of the specified node ordered by their positions in the Weave. Read more
Source§

fn sort_node_children_by( &mut self, id: &K, cmp: impl FnMut(&N, &N) -> Ordering, ) -> bool

Sorts the child nodes of a parent node with the specified identifier using the comparison function cmp. Read more
Source§

fn sort_node_children_by_id( &mut self, id: &K, cmp: impl FnMut(&K, &K) -> Ordering, ) -> bool

Sorts the identifiers of a parent node’s children with the specified identifier using the comparison function cmp. Read more
Source§

fn sort_roots_by(&mut self, cmp: impl FnMut(&N, &N) -> Ordering)

Sorts root nodes (nodes which do not have any parents) using the comparison function cmp. Read more
Source§

fn sort_roots_by_id(&mut self, cmp: impl FnMut(&K, &K) -> Ordering)

Sorts the identifiers of root nodes (nodes which do not have any parents) using the comparison function cmp. Read more
Source§

impl<W, K, N, T: PartialEq> StructuralPartialEq for CountedWeave<W, K, N, T>
where W: Weave<K, N, T> + PartialEq, K: Hash + Copy + Eq + Ord + PartialEq, N: Node<K, T> + PartialEq,

Source§

impl<W, K, N, T> Weave<K, N, T> for CountedWeave<W, K, N, T>
where W: Weave<K, N, T>, K: Hash + Copy + Eq + Ord, N: Node<K, T>,

Source§

type Nodes = <W as Weave<K, N, T>>::Nodes

Mapping between identifiers and nodes.
Source§

type Roots = <W as Weave<K, N, T>>::Roots

Identifiers of root nodes (nodes which do not have any parents).
Source§

fn len(&self) -> usize

Returns the number of nodes stored within the Weave.
Source§

fn is_empty(&self) -> bool

Returns true if the Weave does not contain any nodes.
Source§

fn nodes(&self) -> &Self::Nodes

Returns a reference to the identifier:node mapping.
Source§

fn roots(&self) -> &Self::Roots

Returns a reference to the identifiers of root nodes (nodes which do not have any parents).
Source§

fn contains(&self, id: &K) -> bool

Returns true if the Weave contains a node with the specified identifier.
Source§

fn contains_active(&self, id: &K) -> bool

Returns true if the Weave contains an active node (node.is_active() == true) with the specified identifier. Read more
Source§

fn get_node(&self, id: &K) -> Option<&N>

Returns a reference to the node corresponding to the identifier.
Source§

fn get_ordered_node_identifiers(&mut self, output: &mut Vec<K>)

Builds a list of all node identifiers ordered by their positions in the Weave.
Source§

fn get_ordered_node_identifiers_from(&mut self, id: &K, output: &mut Vec<K>)

Recursively builds a list of all children of the specified node ordered by their positions in the Weave.
Source§

fn get_active_path(&mut self, output: &mut Vec<K>)

Builds a path through the Weave starting at the deepest active node and ending at a root node. Read more
Source§

fn get_path_from(&mut self, id: &K, output: &mut Vec<K>)

Builds a path through the Weave starting at the specified node and ending at a root node. Read more
Source§

fn add_node(&mut self, node: N) -> bool

Inserts a node into the Weave, returning true if the insertion was successful. Read more
Source§

fn set_node_active_status(&mut self, id: &K, value: bool) -> bool

Sets the active status of a node with the specified identifier. Read more
Source§

fn remove_node(&mut self, id: &K) -> Option<N>

Removes a node with the specified identifier, returning its value if it was present within the Weave. Read more
Source§

fn remove_node_tracked(&mut self, id: &K, on_removal: impl FnMut(N)) -> bool

Removes a node with the specified identifier, returning true if it was present within the Weave. Read more
Source§

fn remove_all_nodes(&mut self)

Removes all nodes from the Weave.

Auto Trait Implementations§

§

impl<W, K, N, T> Freeze for CountedWeave<W, K, N, T>
where W: Freeze,

§

impl<W, K, N, T> RefUnwindSafe for CountedWeave<W, K, N, T>

§

impl<W, K, N, T> Send for CountedWeave<W, K, N, T>
where W: Send, K: Send, N: Send, T: Send,

§

impl<W, K, N, T> Sync for CountedWeave<W, K, N, T>
where W: Sync, K: Sync, N: Sync, T: Sync,

§

impl<W, K, N, T> Unpin for CountedWeave<W, K, N, T>
where W: Unpin, K: Unpin, N: Unpin, T: Unpin,

§

impl<W, K, N, T> UnsafeUnpin for CountedWeave<W, K, N, T>
where W: UnsafeUnpin,

§

impl<W, K, N, T> UnwindSafe for CountedWeave<W, K, N, T>

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> ArchiveUnsized for T
where T: Archive,

Source§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
Source§

fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata

Creates the archived version of the metadata for this value.
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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Fallible + Writer + ?Sized,

Source§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
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.