Struct ValueReader
pub struct ValueReader<T> { /* private fields */ }Expand description
A reader of a latest-value JSON track that follows its Subscription.
Returned by Subscription::value_track. When the publisher restarts and
a new broadcast takes over the path, the reader opens the track on the new
broadcast and reads on, the same as media follows the subscription. The
first read after the move returns the new publisher’s current value. The
reader ends only once the subscription closes.
The reader holds the subscription, so the subscription stays open while the reader lives.
A value’s at orders it among the others but is not the writer’s time:
moq-lite 06, which sessions speak, drops frame timestamps, so a track
arrives untimed and at holds the group’s sequence with no timescale. Put
a time in the value itself when the reader needs it.
Implementations§
§impl<T> ValueReader<T>where
T: DeserializeOwned,
impl<T> ValueReader<T>where
T: DeserializeOwned,
pub async fn latest(&mut self) -> Result<Option<Timed<T>>, ValueError>
pub async fn latest(&mut self) -> Result<Option<Timed<T>>, ValueError>
Waits for the newest value, skipping older ones.
Returns None once the subscription closes. Cancellation safe.
§Errors
Fails when a value does not decode, or when the publisher refuses the track, such as a track it does not publish. A track that ends with its broadcast is no error: the reader waits for the next broadcast.