pub struct SubgroupObjectReader {
extensions_present: bool,
prev_object_id: Option<u64>,
group_id: u64,
group_gap: Option<u64>,
}Expand description
Stateful reader/writer for draft-15 subgroup objects.
Carries the running delta state for object IDs and remembers whether extension headers are present on this stream.
Fields§
§extensions_present: bool§prev_object_id: Option<u64>§group_id: u64§group_gap: Option<u64>Implementations§
Source§impl SubgroupObjectReader
impl SubgroupObjectReader
Sourcepub fn new(header: &SubgroupHeader) -> Self
pub fn new(header: &SubgroupHeader) -> Self
Build a reader seeded from the enclosing subgroup header.
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, extension headers on an
object whose status is not Normal: Section 10.2.1.2, “If an endpoint
receives extension headers on Objects 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.
Refuses, with CodecError::MalformedTrack, the Prior Group ID Gap
and Prior Object ID Gap conditions of Section 11.1 and Section 11.2
this stream shows: those PriorGaps::from_properties refuses, “A
Group contains more than one Object with different values for Prior
Group ID Gap”, and “An endpoint receives an Object with a Prior Object
ID Gap covering an Object it previously received” for an Object earlier
on this stream. Self::read_object_meta does not read extension
headers and applies none of them.
fn check_stream_gaps( &mut self, gaps: PriorGaps, prior_object_id: Option<u64>, object_id: u64, ) -> 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.
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.
A zero payload_length makes this a status object, and the status
field is then mandatory on the wire: an absent
SubgroupObject::object_status is written as
ObjectStatus::Normal. The code written is always one draft-15
assigns, because the field cannot hold any other, so the bytes this
produces are always bytes SubgroupObjectReader::read_object accepts.
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.
Does NOT refuse extension headers beside a status other than Normal,
though draft-15 Section 10.2.1.2 forbids them. Such a frame is well
formed and merely non-conforming, this is the only writer a subgroup
object has, and the corpus ships one — so refusing here would leave a
captured violation impossible to reproduce.
SubgroupObject::extensions_permitted reports it instead.