Struct NameSet

Source
pub struct NameSet(/* private fields */);
Expand description

A NameSet contains an immutable list of names.

It provides order-preserving iteration and set operations, and is cheaply clonable.

Implementations§

Source§

impl NameSet

Source

pub fn empty() -> Self

Creates an empty set.

Source

pub fn from_static_names(names: impl IntoIterator<Item = VertexName>) -> NameSet

Creates from a (short) list of known names.

Source

pub fn from_iter<I>(iter: I, hints: Hints) -> NameSet
where I: IntoIterator<Item = Result<VertexName>> + 'static, <I as IntoIterator>::IntoIter: Send + Sync,

Creates from a (lazy) iterator of names.

Source

pub fn from_stream(stream: BoxVertexStream, hints: Hints) -> NameSet

Creates from a (lazy) stream of names with hints.

Source

pub fn from_id_iter_idmap_dag<I>( iter: I, map: Arc<dyn IdConvert + Send + Sync>, dag: Arc<dyn DagAlgorithm + Send + Sync>, ) -> NameSet
where I: IntoIterator<Item = Result<Id>> + 'static, <I as IntoIterator>::IntoIter: Send + Sync,

Creates from a (lazy) iterator of Ids, an IdMap, and a Dag.

Source

pub fn from_id_iter_dag<I>( iter: I, dag: &(impl DagAlgorithm + IdMapSnapshot), ) -> Result<NameSet>
where I: IntoIterator<Item = Result<Id>> + 'static, <I as IntoIterator>::IntoIter: Send + Sync,

Creates from a (lazy) iterator of Ids and a struct with snapshot abilities.

Source

pub fn from_spans_idmap_dag( spans: IdSet, map: Arc<dyn IdConvert + Send + Sync>, dag: Arc<dyn DagAlgorithm + Send + Sync>, ) -> NameSet

Creates from IdSet, [IdMap] and DagAlgorithm.

Source

pub fn from_spans_dag( spans: IdSet, dag: &(impl DagAlgorithm + IdMapSnapshot), ) -> Result<Self>

Creates from IdSet and a struct with snapshot abilities.

Source

pub fn from_evaluate_contains<C>( evaluate: impl Fn() -> Result<NameSet> + Send + Sync + 'static, contains: C, hints: Hints, ) -> NameSet
where C: for<'a> Fn(&'a MetaSet, &'a VertexName) -> Result<bool> + Send + Sync + 'static,

Creates from a function that evaluates to a NameSet, and a contains fast path.

Source

pub fn from_async_evaluate_contains( evaluate: Box<dyn Fn() -> BoxFuture<'static, Result<NameSet>> + Send + Sync>, contains: Box<dyn for<'a> Fn(&'a MetaSet, &'a VertexName) -> BoxFuture<'a, Result<bool>> + Send + Sync>, hints: Hints, ) -> NameSet

Creates from an async function that evaluates to a NameSet, and a async contains fast path.

Source

pub fn difference(&self, other: &NameSet) -> NameSet

Calculates the subset that is only in self, not in other.

Source

pub fn intersection(&self, other: &NameSet) -> NameSet

Calculates the intersection of two sets.

Source

pub fn union(&self, other: &NameSet) -> NameSet

Calculates the union of two sets.

Source

pub fn filter( &self, filter_func: Box<dyn Fn(&VertexName) -> BoxFuture<'_, Result<bool>> + Send + Sync + 'static>, ) -> Self

Filter using the given async function. If filter_func returns true for a vertex, then the vertex will be taken, other it will be skipped.

Source

pub async fn to_parents(&self) -> Result<Option<impl Parents>>

Convert the set to a graph containing only the vertexes in the set. This can be slow on larger sets.

Source

pub fn dag(&self) -> Option<Arc<dyn DagAlgorithm + Send + Sync>>

Obtain the attached dag if available.

Source

pub fn id_map(&self) -> Option<Arc<dyn IdConvert + Send + Sync>>

Obtain the attached IdMap if available.

Source

pub async fn flatten(&self) -> Result<NameSet>

Convert the current set into a flat static set so it can be used in some fast paths. This is useful for some common sets like obsolete() that might be represented by a complex expression.

Source

pub async fn flatten_id( &self, id_map: Arc<dyn IdConvert + Send + Sync>, dag: Arc<dyn DagAlgorithm + Send + Sync>, ) -> Result<NameSet>

Convert this set to a static id set.

Source

pub async fn flatten_names(&self) -> Result<NameSet>

Convert this set to a static name set.

Source

pub fn take(&self, n: u64) -> NameSet

Take the first n items.

Source

pub fn skip(&self, n: u64) -> NameSet

Skip the first n items.

Source

pub fn to_id_set_and_id_map_in_o1( &self, ) -> Option<(IdSet, Arc<dyn IdConvert + Send + Sync>)>

Converts to (IdSet, IdConvert) pair in O(1). If the underlying set cannot provide such information in O(1), return None.

Useful if the callsite wants to have random access (ex. bisect) and control how to resolve in batches.

Trait Implementations§

Source§

impl BitAnd for NameSet

Source§

type Output = NameSet

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Self) -> Self

Performs the & operation. Read more
Source§

impl BitOr for NameSet

Source§

type Output = NameSet

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Self) -> Self

Performs the | operation. Read more
Source§

impl Clone for NameSet

Source§

fn clone(&self) -> NameSet

Returns a copy 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 Debug for NameSet

Source§

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

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

impl Deref for NameSet

Source§

type Target = dyn AsyncNameSetQuery

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<&VertexName> for NameSet

Source§

fn from(name: &VertexName) -> NameSet

Converts to this type from the input type.
Source§

impl<'a> From<(LegacyCodeNeedIdAccess, SpanSet, &'a AbstractNameDag<IdDag<IndexedLogStore>, IdMap, IndexedLogNameDagPath, NameDagState>)> for NameSet

Source§

fn from(value: (LegacyCodeNeedIdAccess, IdSet, &'a NameDag)) -> NameSet

Converts to this type from the input type.
Source§

impl From<VertexName> for NameSet

Source§

fn from(name: VertexName) -> NameSet

Converts to this type from the input type.
Source§

impl Sub for NameSet

Source§

type Output = NameSet

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
Source§

impl SyncNameSetQuery for NameSet

Source§

fn iter(&self) -> Result<Box<dyn NameIter>>

Iterate through the set in defined order.
Source§

fn iter_rev(&self) -> Result<Box<dyn NameIter>>

Iterate through the set in the reversed order.
Source§

fn count(&self) -> Result<usize>

Number of names in this set.
Source§

fn first(&self) -> Result<Option<VertexName>>

The first name in the set.
Source§

fn last(&self) -> Result<Option<VertexName>>

The last name in the set.
Source§

fn is_empty(&self) -> Result<bool>

Test if this set is empty.
Source§

fn contains(&self, name: &VertexName) -> Result<bool>

Test if this set contains a given name.
Source§

fn as_any(&self) -> &dyn Any

For downcasting.
Source§

fn hints(&self) -> &Hints

Get or set optimization hints.
Source§

fn id_convert(&self) -> Option<&dyn IdConvert>

Get an optional IdConvert interface to check hints.

Auto Trait Implementations§

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> TryClone for T
where T: Clone,

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