Skip to main content

FramedRecvStream

Struct FramedRecvStream 

Source
pub struct FramedRecvStream {
    inner: RecvStream,
    buf: BytesMut,
    draft: DraftVersion,
    subgroup_io: Option<SubgroupObjectReader>,
    tracking: Option<(TrackObjects, u64)>,
}
Expand description

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

Fields§

§inner: RecvStream§buf: BytesMut§draft: DraftVersion§subgroup_io: Option<SubgroupObjectReader>

Stateful subgroup object reader.

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

Implementations§

Source§

impl FramedRecvStream

Source

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

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

Source

pub fn stream_id(&self) -> u64

Get the transport-level stream ID.

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, object: u64, status: Option<u64>, ) -> Result<(), ConnectionError>

Judge one object this stream carried against where its track ended.

The object’s Group ID is the stream’s and its Object ID is its own, already resolved from the delta the wire carries; what they are measured against is the end an end-of-track object settled on any stream.

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 fn stop(&mut self, code: u64) -> Result<(), ConnectionError>

Stop reading, telling the peer to stop transmitting with code as the STOP_SENDING application error code, discarding anything unread.

Dropping a receive stream also stops it, but with a hard-coded 0. See RecvStream::stop.

Source

pub async fn received_reset(&mut self) -> Result<Option<u64>, ConnectionError>

Wait for the peer to reset this stream, consuming nothing.

See RecvStream::received_reset for what Ok(None) means and why a caller must not re-poll after it.

Source

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

Read the next control message, or report that the peer finished the stream at a message boundary.

Ok(None) is a clean end and not an error: on a namespace subscription’s stream it is one of the two ways Section 6.1 withdraws the subscription — “closing the stream with either a FIN or RESET_STREAM” — and the other is a reset, which surfaces as TransportError::StreamReset out of the read below.

A stream that ends inside a message is a different thing and stays ConnectionError::UnexpectedEnd: the buffer is empty only at a boundary.

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. Also initializes the internal delta-decoding state.

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-16 subgroup object from this stream using the stateful reader seeded by FramedRecvStream::read_subgroup_header.

Errors with ConnectionError::ExtensionsOnNonNormalStatus on an Object that carries extension headers on a status other than Normal, which draft-16 Section 10.2.1.2 answers with a session close. The Object is consumed from the stream before the check, so the reader stays in step with the wire and a caller that reports the violation and reads on sees the following Object rather than a re-parse of this one.

Source

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

Read the next draft-16 fetch header from this stream.

Source

pub async fn read_fetch_object( &mut self, ) -> Result<(FetchObjectHeader, Vec<u8>), ConnectionError>

Read the next draft-16 fetch object’s header and payload.

The mirror of FramedSendStream::write_fetch_object, and the payload comes back with the header for the reason the codec leaves it on the wire: payload_length says how many bytes follow, and a reader that takes the wrong number of them desynchronises every later object on the stream. Doing it here is the only place that count and the buffer are both in hand.

Stateless, because draft-16’s decoder is: the header comes back with its elided fields still absent — group_id_delta, object_id_delta and the Subgroup ID mode say what each Object inherited rather than what it is. Resolving them against the Object before needs state this draft’s codec does not offer, which drafts 15, 16 and 18 each do in their own way.

§Errors

ConnectionError::UnexpectedEnd when the stream ends inside the header or inside the payload it declared, and ConnectionError::Codec on a Serialization Flags value the draft does not define.

Source

async fn read_object_payload( &mut self, length: &VarInt, ) -> Result<Vec<u8>, ConnectionError>

Take the length payload bytes that follow a fetch object’s header.

Separate from the header read because the header is decoded from a probe cursor that may have to be retried after a fill, and the payload is a flat byte count that never is.

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