pub struct SubgroupObjectReader {
extensions_present: bool,
prev_object_id: Option<u64>,
group_id: u64,
group_gap: Option<u64>,
}Fields§
§extensions_present: bool§prev_object_id: Option<u64>§group_id: u64§group_gap: Option<u64>Implementations§
Source§impl SubgroupObjectReader
impl SubgroupObjectReader
pub fn new(header: &SubgroupHeader) -> Self
Sourcepub fn read_object(
&mut self,
buf: &mut impl Buf,
) -> Result<SubgroupObject, CodecError>
pub fn read_object( &mut self, buf: &mut impl Buf, ) -> Result<SubgroupObject, CodecError>
Decode the next object whole, payload included.
Refuses, with CodecError::InvalidField, properties on an object
whose status is not Normal: Section 11.2.1.2, “If an endpoint receives
properties on an Object with status that is not Normal, it MUST close
the session with a PROTOCOL_VIOLATION.” Self::read_object_meta
frames such an object without judging it, as
DatagramHeader::decode does a datagram.
Refuses, with CodecError::MalformedTrack, the Prior Group ID Gap and
Prior Object ID Gap conditions of Section 12.8 and Section 12.9 this stream
shows: those PriorGaps::from_properties refuses, and “A Group contains
more than one Object with different values for Prior Group ID Gap”. It does
not refuse “An endpoint receives an Object with a Prior Object ID Gap
covering an Object it previously received”: draft-18 Section 2.1 says of an
Object known to exist, “From this state, it can transition to not existing,
but not vice versa”, so whether such a gap makes the Track malformed is
ambiguous. Self::read_object_meta does not read properties and applies
none of them.
fn check_stream_gaps(&mut self, gaps: PriorGaps) -> Result<(), CodecError>
Sourcepub fn read_object_meta(
&mut self,
buf: &mut impl Buf,
) -> Result<SubgroupObjectMeta, CodecError>
pub fn read_object_meta( &mut self, buf: &mut impl Buf, ) -> Result<SubgroupObjectMeta, CodecError>
Decode the next object’s framing without copying its payload.
Consumes exactly the bytes Self::read_object consumes and leaves
the same delta state behind, so the two are interchangeable on a
given stream.
Sourcepub fn write_object(
&mut self,
object: &SubgroupObject,
buf: &mut impl BufMut,
) -> Result<(), CodecError>
pub fn write_object( &mut self, object: &SubgroupObject, buf: &mut impl BufMut, ) -> Result<(), CodecError>
Serialize an object, producing the correct delta encoding.
A zero payload_length writes the object’s status, defaulting to
ObjectStatus::Normal when it is None. The status is typed, so
every value that can reach this method is one draft-18 assigns and one
Self::read_object accepts; there is no status-related error to
return.
Errors with CodecError::InvalidField when object.object_id is
not strictly greater than the previously written object’s ID, since
no valid delta exists for that case.
Errors with CodecError::InvalidField when payload_length is not
exactly payload.len(). The declared length is written ahead of the
payload, so a mismatch is a frame Self::read_object cannot parse
and one no caller could fix by appending bytes.