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
impl FramedSendStream
Sourcepub fn new(inner: SendStream) -> Self
pub fn new(inner: SendStream) -> Self
Create a new framed send stream.
Sourcepub async fn write_control(
&mut self,
msg: &AnyControlMessage,
) -> Result<Vec<u8>, ConnectionError>
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).
Sourcepub async fn write_subgroup_header(
&mut self,
header: &AnySubgroupHeader,
) -> Result<(), ConnectionError>
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.
Sourcepub async fn write_fetch_header(
&mut self,
header: &AnyFetchHeader,
) -> Result<(), ConnectionError>
pub async fn write_fetch_header( &mut self, header: &AnyFetchHeader, ) -> Result<(), ConnectionError>
Write a fetch response header.
Sourcepub async fn write_subgroup_object(
&mut self,
object: &SubgroupObject,
) -> Result<(), ConnectionError>
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.
Sourcepub async fn write_fetch_object(
&mut self,
object: &FetchObject,
) -> Result<(), ConnectionError>
pub async fn write_fetch_object( &mut self, object: &FetchObject, ) -> Result<(), ConnectionError>
Append a draft-09 fetch object (header + payload) to the stream.
Sourcepub async fn finish(&mut self) -> Result<(), ConnectionError>
pub async fn finish(&mut self) -> Result<(), ConnectionError>
Finish the stream (send FIN).