pub struct FramedSendStream {
inner: SendStream,
subgroup_objects: Option<SubgroupStreamState>,
}Expand description
A framed writer for a send stream. Handles MoQT length-prefixed framing.
Fields§
§inner: SendStream§subgroup_objects: Option<SubgroupStreamState>What the subgroup header opened on this stream settled, once one has been written.
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.
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.
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-13 subgroup object (header + payload) to the stream.
Section 9.4.2: “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-13 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).