Skip to main content

FramedSendStream

Struct FramedSendStream 

Source
pub struct FramedSendStream {
    inner: SendStream,
    subgroup_objects: Option<Option<u64>>,
}
Expand description

A framed writer for a send stream. Handles MoQT length-prefixed framing.

Fields§

§inner: SendStream§subgroup_objects: Option<Option<u64>>

The last Object ID written on this subgroup stream, once one has been.

None before the first object; the outer Option is None until a subgroup header has been written, which is what makes an object sent before its header answerable rather than unframed bytes.

Implementations§

Source§

impl FramedSendStream

Source

pub fn new(inner: SendStream) -> Self

Create a new framed send stream.

Source

pub fn stream_id(&self) -> u64

Get the transport-level stream ID.

Source

pub async fn write_control( &mut self, msg: &AnyControlMessage, ) -> Result<Vec<u8>, ConnectionError>

Write a control message to the stream with type+length framing. Returns the raw bytes that were written (for event capture).

Source

pub async fn write_subgroup_header( &mut self, header: &AnySubgroupHeader, ) -> Result<(), ConnectionError>

Write a subgroup stream header. Also opens the Object ID bookkeeping FramedSendStream::write_subgroup_object holds the stream to.

Written through the checked encoder, which on this draft refuses nothing: SUBGROUP_HEADER has one shape here, every field goes out every time, and no type byte selects between them. The drafts that gained a header type table need the refusal, and one call site for all thirteen is what keeps this from being the draft where it was forgotten.

Source

pub async fn write_fetch_header( &mut self, header: &AnyFetchHeader, ) -> Result<(), ConnectionError>

Write a fetch response header.

Source

pub async fn write_subgroup_object( &mut self, object: &SubgroupObject, ) -> Result<(), ConnectionError>

Append a draft-09 subgroup object (header + payload) to the stream.

Section 8.4.1: “A publisher MUST NOT send an Object on a stream if its Object ID is less than a previously sent Object ID within a given group in that stream.” A subgroup stream carries one group, so the Object IDs written here are exactly the ones that sentence compares, and the comparison needs the object before - which no per-header check can see. The state advances only once the object has been written, so declining to write an object leaves the next one measured against the last one kept.

An equal Object ID is refused as well as a smaller one. The draft’s own sentence forbids only “less than”, but an Object ID names an Object within a Group: writing one twice on a stream describes the same Object with two different payloads, and a reader has no way to choose. The dispatch-level writer in the codec draws the line in the same place, and two writers that disagreed about it would be worse than either answer.

§Errors

ConnectionError::DataStreamState if no subgroup header has been written yet, or if object does not advance past the last one written.

Source

pub async fn write_fetch_object( &mut self, object: &FetchObject, ) -> Result<(), ConnectionError>

Append a draft-09 fetch object (header + payload) to the stream.

Source

pub async fn finish(&mut self) -> Result<(), ConnectionError>

Finish the stream (send FIN).

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

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

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

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, 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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