pub struct FramedSendStream {
inner: SendStream,
draft: DraftVersion,
subgroup_io: Option<SubgroupObjectReader>,
}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 encoder. Initialized by
FramedSendStream::write_subgroup_header and used by
FramedSendStream::write_subgroup_object to track the delta-encoded
object ID state.
Implementations§
Source§impl FramedSendStream
impl FramedSendStream
Sourcepub fn new(inner: SendStream, draft: DraftVersion) -> Self
pub fn new(inner: SendStream, draft: DraftVersion) -> Self
Create a new framed send stream for the given draft version.
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 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.
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-14 subgroup object to the stream. Uses the stateful
reader installed by FramedSendStream::write_subgroup_header to
produce the correct delta-encoded object ID. Returns an error if
called before a subgroup header was 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-14 fetch object to the stream. Fetch objects are
self-contained (each carries its own group/subgroup/object IDs and
priority), so no prior write_fetch_header bookkeeping is required.
Append a fetch object to the stream.
Draft-14 derives the declared length from the payload itself rather than holding it as a field, so there is nothing here for the two to disagree about - unlike the subgroup object, whose header carries the length and whose writer has to overwrite it.
§Errors
Whatever the checked encoder refuses: a payload beside a status that forbids one, or a status the draft leaves unassigned. This went through the unchecked encoder, so both were written.
Sourcepub async fn finish(&mut self) -> Result<(), ConnectionError>
pub async fn finish(&mut self) -> Result<(), ConnectionError>
Finish the stream (send FIN).
Sourcepub fn draft(&self) -> DraftVersion
pub fn draft(&self) -> DraftVersion
Returns the draft version this stream is framed for.