Skip to main content

View

Struct View 

Source
pub struct View<T> { /* private fields */ }
Expand description

A reader’s view of one owner’s state for one interface, as its deliveries, its reads and that owner’s heartbeats make it (core §7.5’s heartbeat; #978’s F2). No rule adopts the heartbeat yet, so nothing here changes a judge: a heartbeat that confirms a member is a confirmation of it, as a put is (§2.5), and View::observation ages the member from the later of the two.

  • The members are each collection’s that the reader heard: a put with its in-band stamp, a delete, or a read’s answer (View::replace). A put older than the one held, within one run, is not taken.
  • A heartbeat (View::apply) confirms, in each collection the view follows (View::follow), each member vouched for, when the section’s digest is the view’s and its live count is too. A reader follows only a collection it hears whole: one whose template it subscribes with no parameter bound.
  • A divergence confirms nothing in its collection. After two in a row the collection is due a read (View::reread_due), whose answer replaces what the view holds.
  • A gap in the heartbeat key’s seqs is a heartbeat lost: the view’s members are incomplete until one arrives in sequence.

Implementations§

Source§

impl<T: Arrival> View<T>

Source

pub fn new(layout: Layout) -> Self

An empty view of a revision’s collections, following none.

Source

pub fn layout(&self) -> &Layout

The revision’s layout.

Source

pub fn follow(&mut self, index: usize) -> bool

Follows the collection at index; false when there is none.

Source

pub fn follow_resource(&mut self, resource: &str) -> bool

Follows the collection named <kind token>/<template>; false when it is none.

Source

pub fn follows_any(&self) -> bool

Whether it follows any collection.

Source

pub fn put(&mut self, key: &str, stamp: Option<Stamp>, at: T)

A put of key heard at at, with its in-band stamp (None when it carried none). A key of no collection is not held, and a put older than the one held within one run is not taken.

Source

pub fn delete(&mut self, key: &str, stamp: Option<Stamp>, at: T)

A delete of key heard at at, with its in-band stamp where its attachment carried one.

Source

pub fn replace<'k>( &mut self, index: usize, live: impl IntoIterator<Item = (&'k str, Option<Stamp>)>, at: T, )

A complete read of the collection at index (S4’s answer, or a snapshot once #977 lands), at at: its live members replace the view’s, a member it left out leaving the view, and the collection is no longer due a read. A put heard after the read was asked is the caller’s to apply again after it (core §4.2).

Source

pub fn reread<'k>( &mut self, index: usize, live: impl IntoIterator<Item = (&'k str, Option<Stamp>)>, asked: T, at: T, )

A re-read of the collection at index (freshness.v2 §2.5): its answer, asked at asked and arrived at at, merged with what the view heard of the collection from asked on, as core §4.2 merges a late joiner’s seed. The answer replaces the collection (View::replace); then each member heard live since asked is kept where the answer has none of it, or holds a lower seq of its run. Across two runs the answer’s stands, as core §4.3’s consumer rule accepts another run.

Source

pub fn digest(&self, index: usize) -> Option<Digest>

The view’s digest of a collection: None while it holds a live member whose put carried no in-band stamp, which no digest counts.

Source

pub fn apply(&mut self, tag: Tag, stamp: Stamp, body: &[u8], at: T) -> Applied

A heartbeat heard at at: CH’s tag, its stamp and its body. See View’s doc for what it confirms.

Source

pub fn apply_group( &mut self, class: Class, entry: &Entry, group: &Group, time: Time, at: T, ) -> GroupRead

One group of a read owner heartbeat of class, heard at at (v2 §2.5’s “An owner heartbeat”, step 3 from “Not followed” on): entry is what core §8.6 read its index as (crate::heartbeat::Group::entry), and time the owner heartbeat’s. The caller has read the owner heartbeat on its key first (Views::apply_owner does both): this moves no sequence.

  • Not followed: the entry names another interface, or the view follows no collection.
  • Another revision: the entry’s revision is not the view’s, or the group’s tag is not that revision’s.
  • Refused: core §7.5 refuses its sections, parsed whole, the other class’s too.
  • Read: each followed collection of class as a heartbeat’s section is read, on the collection’s one count of divergences in a row; a followed one of the other class is SectionRead::OtherClass, unread and uncounted. The group is a heartbeat applied (View::heartbeats, View::owner_time) only when a section was read: one on the other class’s key reads none.
Source

pub fn confirm(&mut self, key: &str, at: T)

A GET’s snapshot vouched for key’s live value at at (v2 §2.6, text 0.7; core §7.5’s confirmation): kept as a heartbeat’s would be, when it is later than what the view held. A deleted member, or one the view does not hold, is left as it is.

Source

pub fn confirmed(&self, key: &str) -> Option<T>

The last heartbeat that vouched for key since its last mutation.

Source

pub fn reread_due(&self) -> Vec<usize>

The collections due a read: two heartbeats in a row diverged there.

Source

pub fn gap(&self) -> bool

Whether the last heartbeat came after a gap in its key’s seqs: the interface’s own heartbeat key’s. A gap on an owner heartbeat key is Views::gap’s.

Source

pub fn follows(&self, index: usize) -> bool

Whether it follows the collection at index.

Source

pub fn classes(&self) -> Vec<Class>

The classes of the collections it follows, link first: the provider’s owner heartbeat keys a subscriber subscribes to beside its heartbeat key (v2 §2.5, “Both forms”).

Source

pub fn owner_time(&self) -> Option<Time>

The owner’s time in the last heartbeat applied, or in the last owner heartbeat a group of which read a section of a followed collection.

Source

pub fn last_heartbeat(&self) -> Option<Stamp>

The last heartbeat applied on the interface’s own heartbeat key: its stamp. An owner heartbeat’s is its key’s (Views::last).

Source

pub fn heartbeats(&self) -> u64

How many heartbeats it applied, each group among them that read a section of a followed collection, on its class’s key.

Source

pub fn last(&self, key: &str, now: T) -> Option<Last>

key’s last confirmation at now (§2.5): the later of its last mutation and the last heartbeat that vouched for it, as a Last; None for a member the view does not hold.

Source

pub fn observation( &self, key: &str, now: T, listened: Duration, complete: bool, ) -> Observation

key as a subscription’s observation at now (§2.5), the view standing in for its deliveries: its last confirmation, how long the subscription has listened, and complete when the subscription lost nothing (complete) and no heartbeat was lost.

Trait Implementations§

Source§

impl<T: Clone> Clone for View<T>

Source§

fn clone(&self) -> Self

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<T: Debug> Debug for View<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Forget for View<T>

§

impl<T> Freeze for View<T>

§

impl<T> Move for View<T>

§

impl<T> RefUnwindSafe for View<T>
where T: RefUnwindSafe,

§

impl<T> Send for View<T>
where RawVecInner: Send, NodeRef<Owned, String, Held<T>, LeafOrInternal>: Send, BoxRaw<(String, Held<T>)>: Send,

§

impl<T> Sync for View<T>
where RawVecInner: Sync, NodeRef<Owned, String, Held<T>, LeafOrInternal>: Sync, BoxRaw<(String, Held<T>)>: Sync,

§

impl<T> Unpin for View<T>
where *const u8 is !null: Unpin, *const LeafNode<String, Held<T>> is !null: Unpin, Box<(String, Held<T>)>: Unpin,

§

impl<T> UnsafeUnpin for View<T>

§

impl<T> UnwindSafe for View<T>
where RawVecInner: UnwindSafe, BTreeMap<String, Held<T>>: UnwindSafe,

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

Source§

fn as_node(&self) -> &T

Source§

impl<T> AsNodeMut<T> for T

Source§

fn as_node_mut(&mut self) -> &mut T

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.