pub struct FetchObjectReader { /* private fields */ }Expand description
Resolves the delta-encoded fields of the frames on one FETCH stream.
Draft-19 Section 11.4.4.1 defines nearly every field of a fetch frame against “the prior Object”, so no frame after the first can be understood on its own. This holds what the frames so far established, in the two parts the draft keeps separate: Section 11.4.4.2 says that after an End of Range marker the prior Group ID and Object ID are the marker’s, while the prior Subgroup ID and Priority are still “from the last actual Object before the End of Range indicator”.
Every rule the section answers with a PROTOCOL_VIOLATION is refused here
with CodecError::InvalidField: a first Object that references fields no
prior Object established, a Subgroup ID or Priority inherited when there is
none to inherit, and an arithmetic result outside the 64-bit range.
Implementations§
Source§impl FetchObjectReader
impl FetchObjectReader
Sourcepub fn new(group_order: GroupOrder) -> Self
pub fn new(group_order: GroupOrder) -> Self
A reader for a stream whose Groups arrive in group_order.
Sourcepub fn read_object_header(
&mut self,
buf: &mut impl Buf,
) -> Result<FetchObject, CodecError>
pub fn read_object_header( &mut self, buf: &mut impl Buf, ) -> Result<FetchObject, CodecError>
Decode the next frame’s header and resolve its fields.
Consumes the header only. The Object Payload is
header.payload_length bytes and stays in buf, so a caller that
forwards payloads never copies them and one that ignores them can skip.
Errors with CodecError::InvalidField on every rule
Section 11.4.4.1 states:
- “The first Object MUST include a Group ID Delta and Object ID Delta, and these values are the absolute Group ID and Object ID. If the first Object in the FETCH response uses a flag that references fields in the prior Object, the Subscriber MUST close the session with a PROTOCOL_VIOLATION.” Each such flag is refused where it is read, so the reason survives: a missing delta, an inherited Priority and an inherited Subgroup ID are three different frames, all of them referencing an Object that does not exist.
- “If the computed Group ID would be less than 0 or greater than 2^64-1, the Subscriber MUST close the Session with error ‘PROTOCOL_VIOLATION’” — the descending and ascending ends of the same rule.
- “If the computed Object ID would be greater than 2^64-1, the Subscriber MUST close the Session with error ‘PROTOCOL_VIOLATION’.”
Trait Implementations§
Source§impl Clone for FetchObjectReader
impl Clone for FetchObjectReader
Source§fn clone(&self) -> FetchObjectReader
fn clone(&self) -> FetchObjectReader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more