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 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 owner_time(&self) -> Option<Time>
pub fn owner_time(&self) -> Option<Time>
The owner’s time in the last heartbeat applied.
Sourcepub fn last_heartbeat(&self) -> Option<Stamp>
pub fn last_heartbeat(&self) -> Option<Stamp>
The last heartbeat applied: its stamp.
Sourcepub fn heartbeats(&self) -> u64
pub fn heartbeats(&self) -> u64
How many heartbeats it applied.
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>
impl<T> RefUnwindSafe for View<T>
impl<T> Send for View<T>
impl<T> Sync for View<T>
impl<T> Unpin for View<T>
impl<T> UnsafeUnpin for View<T>
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