Skip to main content

Snapshot

Struct Snapshot 

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

Publishes a latest-value JSON track, advertised in the catalog for as long as this handle lives.

Every update supersedes the last, so a consumer reads only the newest value. For a log where every record survives, use Stream.

Implementations§

Source§

impl<T: Serialize> Snapshot<T>

Source

pub fn name(&self) -> &str

The track name, which is also the catalog key.

Source

pub fn consume(&self) -> Subscriber

Create a subscriber for the underlying track.

Source

pub fn demand(&self) -> Demand

A watch-only handle to whether this track has subscribers.

Source

pub fn poll_refresh(&self, waiter: &Waiter) -> Poll<Result<()>>

Wait for a joiner to want a fresh group, then restate the value in one; see moq_json::snapshot::Producer::poll_refresh.

A restatement is not a new value, so it measures neither jitter nor delay.

Source

pub async fn refresh(&self) -> Result<()>

Wait for a joiner to want a fresh group, then restate the value in one; see moq_json::snapshot::Producer::poll_refresh.

A restatement is not a new value, so it measures neither jitter nor delay.

Awaits poll_refresh.

Source

pub fn update(&mut self, value: &T, timestamp: Timestamp) -> Result<()>

Publish a new value at timestamp on the broadcast clock, superseding the previous one.

The value is written at that timestamp and measures the entry’s jitter and delay; one ahead of now measures as zero delay. An unchanged value writes nothing and measures nothing.

Source

pub fn finish(self) -> Result<()>

Finish the track and retire its catalog entry.

Consumes the handle, so a write after finishing cannot be expressed. Leaving the entry advertising a closed track would only mislead a consumer that subscribed afterwards, so dropping the handle without finishing retires the entry too.

Source

pub fn abort(self, err: Error) -> Result<()>

Abort the track with err, which consumers see in place of a clean end, and retire its catalog entry.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Snapshot<T>

§

impl<T> !UnwindSafe for Snapshot<T>

§

impl<T> Freeze for Snapshot<T>

§

impl<T> Send for Snapshot<T>

§

impl<T> Sync for Snapshot<T>

§

impl<T> Unpin for Snapshot<T>

§

impl<T> UnsafeUnpin for Snapshot<T>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more