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>
impl<T: Arrival> View<T>
Sourcepub fn follow(&mut self, index: usize) -> bool
pub fn follow(&mut self, index: usize) -> bool
Follows the collection at index; false when there is none.
Sourcepub fn follow_resource(&mut self, resource: &str) -> bool
pub fn follow_resource(&mut self, resource: &str) -> bool
Follows the collection named <kind token>/<template>; false
when it is none.
Sourcepub fn follows_any(&self) -> bool
pub fn follows_any(&self) -> bool
Whether it follows any collection.
Sourcepub fn put(&mut self, key: &str, stamp: Option<Stamp>, at: T)
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.
Sourcepub fn delete(&mut self, key: &str, stamp: Option<Stamp>, at: T)
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.
Sourcepub fn replace<'k>(
&mut self,
index: usize,
live: impl IntoIterator<Item = (&'k str, Option<Stamp>)>,
at: T,
)
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).
Sourcepub fn reread<'k>(
&mut self,
index: usize,
live: impl IntoIterator<Item = (&'k str, Option<Stamp>)>,
asked: T,
at: T,
)
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.
Sourcepub fn digest(&self, index: usize) -> Option<Digest>
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.
Sourcepub fn apply(&mut self, tag: Tag, stamp: Stamp, body: &[u8], at: T) -> Applied
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.
Sourcepub fn apply_group(
&mut self,
class: Class,
entry: &Entry,
group: &Group,
time: Time,
at: T,
) -> GroupRead
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
classas a heartbeat’s section is read, on the collection’s one count of divergences in a row; a followed one of the other class isSectionRead::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.
Sourcepub fn confirm(&mut self, key: &str, at: T)
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.
Sourcepub fn confirmed(&self, key: &str) -> Option<T>
pub fn confirmed(&self, key: &str) -> Option<T>
The last heartbeat that vouched for key since its last mutation.
Sourcepub fn reread_due(&self) -> Vec<usize>
pub fn reread_due(&self) -> Vec<usize>
The collections due a read: two heartbeats in a row diverged there.
Sourcepub fn gap(&self) -> bool
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.
Sourcepub fn classes(&self) -> Vec<Class>
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”).
Sourcepub fn owner_time(&self) -> Option<Time>
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.
Sourcepub fn last_heartbeat(&self) -> Option<Stamp>
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).
Sourcepub fn heartbeats(&self) -> u64
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.
Sourcepub fn last(&self, key: &str, now: T) -> Option<Last>
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.
Sourcepub fn observation(
&self,
key: &str,
now: T,
listened: Duration,
complete: bool,
) -> Observation
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§
Auto Trait Implementations§
impl<T> Forget for View<T>
impl<T> Freeze for View<T>where
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Collection>: Freeze,
PhantomData<(KindToken, Template, Option<usize>)>: Freeze,
PhantomData<bool>: Freeze,
*const LeafNode<String, Held<T>> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Held<T>)>>: Freeze,
PhantomData<u32>: Freeze,
impl<T> Move for View<T>
impl<T> RefUnwindSafe for View<T>where
T: RefUnwindSafe,
impl<T> Send for View<T>
impl<T> Sync for View<T>
impl<T> Unpin for View<T>
impl<T> UnsafeUnpin for View<T>where
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Collection>: UnsafeUnpin,
PhantomData<(KindToken, Template, Option<usize>)>: UnsafeUnpin,
PhantomData<bool>: UnsafeUnpin,
*const LeafNode<String, Held<T>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Held<T>)>>: UnsafeUnpin,
PhantomData<u32>: UnsafeUnpin,
impl<T> UnwindSafe for View<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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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