Skip to main content

Fragment

Struct Fragment 

Source
pub struct Fragment { /* private fields */ }
Expand description

Re-export of Fragment. A rooted (or multi-root) fragment of a knowledge graph.

A fragment is a TribleSet plus a (possibly empty) set of “exported” entity ids that act as entry points into the contained facts. Exports are not privileged in the graph model itself; they are simply the ids the producer wants to hand back to the caller as the fragment’s interface.

Implementations§

Source§

impl Fragment

Source

pub fn empty() -> Self

Creates an empty fragment with no exports and no facts.

Source

pub fn rooted(root: Id, facts: TribleSet) -> Self

Creates a fragment that exports a single root id.

Source

pub fn new<I>(exports: I, facts: TribleSet) -> Self
where I: IntoIterator<Item = Id>,

Creates a fragment with the given exported ids.

Export ids are canonicalized as a set (duplicates are ignored). Empty exports are allowed.

Source

pub fn exports(&self) -> impl Iterator<Item = Id> + '_

Returns the exported ids for this fragment, in deterministic (lexicographic) order.

Source

pub fn root(&self) -> Option<Id>

Returns the single exported id if this fragment is rooted.

Source

pub fn facts(&self) -> &TribleSet

Source

pub fn into_facts(self) -> TribleSet

Source

pub fn into_parts(self) -> (PATCH<16>, TribleSet)

Methods from Deref<Target = TribleSet>§

Source

pub fn intersect(&self, other: &Self) -> Self

Returns a new set containing only tribles present in both sets.

Source

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

Returns a new set containing tribles in self but not in other.

Source

pub fn len(&self) -> usize

Returns the number of tribles in the set.

Source

pub fn is_empty(&self) -> bool

Returns true when the set contains no tribles.

Source

pub fn fingerprint(&self) -> TribleSetFingerprint

Returns a fast fingerprint suitable for in-memory caching.

The fingerprint matches TribleSet equality, but it is not stable across process boundaries because PATCH uses a per-process hash key.

Source

pub fn contains(&self, trible: &Trible) -> bool

Returns true when the exact trible is present in the set.

Source

pub fn value_in_range<V: ValueSchema>( &self, variable: Variable<V>, min: Value<V>, max: Value<V>, ) -> TribleSetRangeConstraint

Creates a constraint that proposes only values in the byte range [min, max] (inclusive) using the VEA index with infixes_range.

Use with and! alongside a pattern! for efficient range queries:

find!(ts: Value<NsTAIInterval>,
    and!(
        pattern!(&data, [{ ?id @ attr: ?ts }]),
        data.value_in_range(ts, min_ts, max_ts),
    )
)
Source

pub fn iter(&self) -> TribleSetIterator<'_>

Iterates over all tribles in EAV order.

Trait Implementations§

Source§

impl Add<Fragment> for TribleSet

Source§

type Output = TribleSet

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Fragment) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<TribleSet> for Fragment

Source§

type Output = Fragment

The resulting type after applying the + operator.
Source§

fn add(self, rhs: TribleSet) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Fragment

Source§

type Output = Fragment

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Fragment> for TribleSet

Source§

fn add_assign(&mut self, rhs: Fragment)

Performs the += operation. Read more
Source§

impl AddAssign<TribleSet> for Fragment

Source§

fn add_assign(&mut self, rhs: TribleSet)

Performs the += operation. Read more
Source§

impl AddAssign for Fragment

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Fragment

Source§

fn clone(&self) -> Fragment

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 Debug for Fragment

Source§

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

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

impl Default for Fragment

Source§

fn default() -> Fragment

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

impl Deref for Fragment

Source§

type Target = TribleSet

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl From<Fragment> for TribleSet

Source§

fn from(value: Fragment) -> Self

Converts to this type from the input type.
Source§

impl<'a> IntoIterator for &'a Fragment

Source§

type Item = &'a Trible

The type of the elements being iterated over.
Source§

type IntoIter = TribleSetIterator<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for Fragment

Source§

fn eq(&self, other: &Fragment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Spread for Fragment

Source§

type Item = Id

The type of each yielded value.
Source§

type Iter = IntoIter<Id>

The iterator type returned by spread.
Source§

fn spread(self) -> (Self::Iter, TribleSet)

Decomposes the value into an iterator of items and extra facts to merge.
Source§

impl Eq for Fragment

Source§

impl StructuralPartialEq for Fragment

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<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> 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> 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