pub struct Stamp<T> { /* private fields */ }Expand description
A multiset of timestamps affixed to a message, stored sorted.
The elements are stored in increasing order under Ord so that Eq, Ord,
and Hash are structural. Stamps built by insertion are minimal antichains;
stamps mapped across scope boundaries may contain comparable or duplicate
elements, whose multiplicities are significant for progress accounting.
Equality compares multisets, not the sets of times they contain: {a} and
{a, a} are different stamps, as they are accounted differently.
As with Antichain, the storage holds a single
element inline, so the overwhelmingly common zero- and one-element stamps
require no allocation.
Implementations§
Source§impl<T> Stamp<T>
impl<T> Stamp<T>
Sourcepub fn into_elements(self) -> Vec<T>
pub fn into_elements(self) -> Vec<T>
The elements of the stamp, by value, in increasing Ord order.
Sourcepub fn as_singleton(&self) -> Option<&T>
pub fn as_singleton(&self) -> Option<&T>
The sole element of the stamp, if the stamp is a singleton.
Sourcepub fn expect_singleton(&self) -> &Twhere
T: Debug,
pub fn expect_singleton(&self) -> &Twhere
T: Debug,
The sole element of the stamp; panics if the stamp is not a singleton.
This supports pre-stamp interfaces that insist on a single timestamp per message; such interfaces cannot be used with multi- or zero-element stamps.
Source§impl<T: TotalOrder> Stamp<T>
impl<T: TotalOrder> Stamp<T>
Sourcepub fn least(&self) -> Option<&T>
pub fn least(&self) -> Option<&T>
The least element of the stamp, if the stamp is non-empty.
Only totally ordered stamps have a least element. A non-empty stamp over a total order has one however many elements it contains, and it is the time at which the message may first result in downstream work.
Elements are stored in Ord order, but TotalOrder speaks only of PartialOrder
and need not agree with Ord, so this is a reduction rather than first().
Source§impl<T: PartialOrder + Ord> Stamp<T>
impl<T: PartialOrder + Ord> Stamp<T>
Sourcepub fn insert(&mut self, element: T) -> bool
pub fn insert(&mut self, element: T) -> bool
Inserts element unless it is redundant, removing elements it dominates.
Returns true iff the element was inserted.
Sourcepub fn less_equal(&self, time: &T) -> bool
pub fn less_equal(&self, time: &T) -> bool
True iff some element of the stamp is less or equal to time.
Sourcepub fn map_into<T2: PartialOrder + Ord>(
&self,
logic: impl FnMut(&T) -> Option<T2>,
) -> Stamp<T2>
pub fn map_into<T2: PartialOrder + Ord>( &self, logic: impl FnMut(&T) -> Option<T2>, ) -> Stamp<T2>
Maps each element through logic, discarding None results and
restoring minimality and canonical order.
This is the shape required when timestamps traverse path summaries (feedback edges), where elements may fail to traverse, or may become comparable after mapping. It may only be used by operators that account for their own consumed and produced messages, as it changes the number of pointstamps a message is accounted at.
Sourcepub fn map_pointwise<T2: Ord>(&self, logic: impl FnMut(&T) -> T2) -> Stamp<T2>
pub fn map_pointwise<T2: Ord>(&self, logic: impl FnMut(&T) -> T2) -> Stamp<T2>
Maps each element through logic, preserving the number of elements and
restoring sorted order, but not minimality.
This is the shape required at scope boundaries (enter and leave), whose produced and consumed accounting is inferred independently at either end of the channel from the stamp itself: the counts must agree element-wise, so the map must not collapse elements that become comparable or equal after mapping (as when leaving a scope projects away a timestamp coordinate). The resulting stamp may contain comparable or duplicate elements; this weakens no guarantee, as the stamp promises only that message contents are greater or equal to some element.
Trait Implementations§
Source§impl<T> Columnar for Stamp<T>
impl<T> Columnar for Stamp<T>
Source§type Container = StampContainer<<SmallVec<[T; 1]> as Columnar>::Container>
type Container = StampContainer<<SmallVec<[T; 1]> as Columnar>::Container>
Source§fn copy_from<'a>(&mut self, other: Ref<'a, Self>)
fn copy_from<'a>(&mut self, other: Ref<'a, Self>)
self from a reference. Read moreSource§fn into_owned<'a>(other: Ref<'a, Self>) -> Self
fn into_owned<'a>(other: Ref<'a, Self>) -> Self
Self from Self::Ref<'a>.Source§fn as_columns<'a, I>(selves: I) -> Self::Containerwhere
I: IntoIterator<Item = &'a Self>,
Self: 'a,
fn as_columns<'a, I>(selves: I) -> Self::Containerwhere
I: IntoIterator<Item = &'a Self>,
Self: 'a,
Source§fn into_columns<I>(selves: I) -> Self::Containerwhere
I: IntoIterator<Item = Self>,
Self: Sized,
fn into_columns<I>(selves: I) -> Self::Containerwhere
I: IntoIterator<Item = Self>,
Self: Sized,
Source§impl<'de, T: Deserialize<'de> + Ord> Deserialize<'de> for Stamp<T>
Deserialization sorts the elements, as the bytes need not come from a valid Stamp.
impl<'de, T: Deserialize<'de> + Ord> Deserialize<'de> for Stamp<T>
Deserialization sorts the elements, as the bytes need not come from a valid Stamp.
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl<T: Eq> Eq for Stamp<T>
Source§impl<T: PartialOrder + Ord> FromIterator<T> for Stamp<T>
impl<T: PartialOrder + Ord> FromIterator<T> for Stamp<T>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl<'a, T> IntoIterator for &'a Stamp<T>
impl<'a, T> IntoIterator for &'a Stamp<T>
Source§impl<T: Ord> Ord for Stamp<T>
impl<T: Ord> Ord for Stamp<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T, R0> PartialEq<Stamp<T>> for StampReference<R0>
impl<T, R0> PartialEq<Stamp<T>> for StampReference<R0>
Source§impl<T: PartialOrd> PartialOrd for Stamp<T>
impl<T: PartialOrd> PartialOrd for Stamp<T>
Source§impl<'columnar, T, C0> Push<&'columnar Stamp<T>> for StampContainer<C0>
impl<'columnar, T, C0> Push<&'columnar Stamp<T>> for StampContainer<C0>
Source§impl<T, C0> Push<Stamp<T>> for StampContainer<C0>
impl<T, C0> Push<Stamp<T>> for StampContainer<C0>
impl<T: PartialEq> StructuralPartialEq for Stamp<T>
Auto Trait Implementations§
impl<T> Freeze for Stamp<T>
impl<T> RefUnwindSafe for Stamp<T>
impl<T> Send for Stamp<T>
impl<T> Sync for Stamp<T>
impl<T> Unpin for Stamp<T>
impl<T> UnsafeUnpin for Stamp<T>
impl<T> UnwindSafe for Stamp<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Data for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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