Skip to main content

Stream

Struct Stream 

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

Publishes an append-log JSON track, advertised in the catalog for as long as this handle lives.

Every append is preserved and delivered in order. For a latest-value document, use Snapshot.

Implementations§

Source§

impl<T: Serialize> Stream<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.

Still hands one back once a failed write has ended the log: the subscriber surfaces the abort on its first read.

Source

pub fn demand(&self) -> Demand

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

Source

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

Append one record to the log at timestamp on the broadcast clock.

A record that cannot be written ends the track (see moq_json::stream::Producer::append) and retires the catalog entry with it. A record refused with [moq_net::Error::FrameTooLarge], [moq_net::Error::GroupTooLarge], or [moq_net::Error::TimestampMismatch] leaves both intact, since nothing was written. A catalog error publishing the measured bitrate is returned after the record was written, so the track stays open and a retry would duplicate it.

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 Stream<T>

§

impl<T> !UnwindSafe for Stream<T>

§

impl<T> Freeze for Stream<T>

§

impl<T> Send for Stream<T>

§

impl<T> Sync for Stream<T>

§

impl<T> Unpin for Stream<T>

§

impl<T> UnsafeUnpin for Stream<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