Skip to main content

FramedSendStream

Struct FramedSendStream 

Source
pub struct FramedSendStream {
    inner: SendStream,
    draft: DraftVersion,
    subgroup_io: Option<SubgroupObjectReader>,
    fetch_io: Option<FetchObjectReader>,
}
Expand description

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

Fields§

§inner: SendStream§draft: DraftVersion§subgroup_io: Option<SubgroupObjectReader>

Stateful subgroup object writer (tracks delta encoding state and extension-presence flag, seeded from the stream’s SubgroupHeader).

§fetch_io: Option<FetchObjectReader>

Stateful fetch object writer, seeded from the stream’s FetchHeader. A fetch object inherits fields from the object before it, so the writer has to have seen that object; without this the first one has nothing to inherit from and is refused.

Implementations§

Source§

impl FramedSendStream

Source

pub fn new(inner: SendStream, draft: DraftVersion) -> Self

Create a new framed send stream for the given draft version.

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 initializes the internal delta-encoding state used by FramedSendStream::write_subgroup_object.

The header is refused, and nothing is written, if its fields disagree with its own stream type. That check has to happen here rather than at the first object: the type is what every object after it is framed against, so a header that went out saying the wrong thing cannot be taken back.

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-15 subgroup object to the stream. Uses the stateful writer seeded from FramedSendStream::write_subgroup_header to produce correct delta-encoded object IDs.

Source

pub async fn write_fetch_object( &mut self, header: &FetchObjectHeader, payload: &[u8], ) -> Result<(), ConnectionError>

Append a fetch object to the stream.

The fetch stream had a header writer and no object writer, so a caller could open one and put nothing on it through this type.

Draft-15 delta-encodes a fetch object against the one before it, so this needs the same stream state the subgroup path keeps, seeded by write_fetch_header. An object that inherits a field from a previous object that does not exist is refused there rather than written as a zero.

The declared length comes from the payload rather than from the caller’s field: a header that disagrees with the bytes beside it desynchronises every object after it on the stream, and nothing downstream can recover.

§Errors

ConnectionError::DataStreamState if no fetch header has been written on this stream, and ConnectionError::Codec for a header the writer refuses.

Source

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

Finish the stream (send FIN).

Source

pub fn draft(&self) -> DraftVersion

Returns the draft version this stream is framed for.

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