Skip to main content

FramedRecvStream

Struct FramedRecvStream 

Source
pub struct FramedRecvStream {
    inner: RecvStream,
    buf: BytesMut,
    tracking: Option<(TrackObjects, u64)>,
    subgroup_has_extensions: bool,
}
Expand description

A framed reader for a recv stream. Handles MoQT varint-length decoding.

Fields§

§inner: RecvStream§buf: BytesMut§tracking: Option<(TrackObjects, u64)>

The record this stream’s objects are measured against, and the Group ID its header named.

One group for the whole stream: a subgroup header names it once and no object header repeats it. None on a stream that was never given one — a stream for an alias no live binding names, and every stream built outside Connection::accept_subgroup_stream — and such a stream reads exactly as it did before this existed.

§subgroup_has_extensions: bool

Whether the subgroup stream this reader is on carries an extension block on every object.

The stream’s Type says so and nothing in an object header repeats it, so a reader that does not remember the Type cannot parse the objects at all: on an extensions-bearing stream it reads the Extension Headers Length as the Object Payload Length and every field after it is nonsense.

Set by FramedRecvStream::read_subgroup_header and read by FramedRecvStream::read_subgroup_object. false until a subgroup header has been read, which is the only order those two may be called in.

Implementations§

Source§

impl FramedRecvStream

Source

pub fn new(inner: RecvStream) -> Self

Create a new framed receive stream.

Source

fn measure_objects_against(&mut self, objects: TrackObjects, group: u64)

Measure this stream’s objects against objects, all of them in group.

Called by Connection::accept_subgroup_stream once the header has been read, which is the only point at which both the track and the group are known.

Source

fn note_subgroup_object( &self, header: &ObjectHeader, ) -> Result<(), ConnectionError>

Record or judge one object this stream carried.

The whole of Section 9.2.1.1’s rule that a single header cannot settle: the object’s Group ID is the stream’s, its Object ID is its own, and what they are measured against is everything the track has carried on any stream.

Source

pub fn stream_id(&self) -> u64

Get the transport-level stream ID.

Source

async fn fill(&mut self) -> Result<bool, ConnectionError>

Read more data from the stream into the internal buffer.

Source

async fn ensure(&mut self, n: usize) -> Result<(), ConnectionError>

Ensure at least n bytes are available in the buffer.

Source

pub async fn read_control( &mut self, capture_raw: bool, ) -> Result<(AnyControlMessage, Option<Vec<u8>>), ConnectionError>

Read a control message from the stream.

When capture_raw is true, the returned tuple includes a clone of the framed wire bytes (for observer emission). When false, the second element is None and the payload clone is skipped.

Source

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

Read a subgroup stream header.

Source

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

Read a fetch response header.

Source

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

Read the next draft-12 subgroup object (header + payload).

Whether an object carries an extension block is a property of the stream’s Type, not of the object, so this reads it from the header FramedRecvStream::read_subgroup_header recorded rather than assuming either answer. Assuming “no extensions” is not a conservative default: on a stream whose Type announces them the Extension Headers Length is read as the Object Payload Length, and every object on the stream comes back wrong instead of being refused.

It is also what puts the rule binding extension headers to Object Status within reach on a subgroup stream. A reader that never reads the block cannot notice that a non-existent Object carried one.

Source

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

Read the next draft-12 fetch object (header + payload).

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