pub struct FetchObjectWriter {
group_order: GroupOrder,
prior_location: Option<(u64, u64)>,
prior_subgroup_id: Option<u64>,
prior_publisher_priority: Option<u8>,
}Expand description
Re-encodes resolved fetch entries onto one FETCH stream.
The inverse of FetchObjectReader, for a caller writing a different
stream from the entries it read: removing an entry changes what the ones
after it are encoded against. The entry’s own header is the preference;
wherever its shape still encodes the same meaning against the new
predecessor it is kept, so a stream with nothing removed is reproduced byte
for byte.
CodecError::InvalidField where no encoding exists: a Group ID that moves
against the Group Order, an Object ID that does not advance, an Object with
neither a Subgroup ID nor the Datagram bit, an End of Group or End of Track
whose Object is not the one written before it, and the arithmetic
overflows.
Fields§
§group_order: GroupOrder§prior_location: Option<(u64, u64)>Group ID and Object ID the next entry is encoded against.
prior_subgroup_id: Option<u64>Subgroup ID of the last actual Object written that had one.
prior_publisher_priority: Option<u8>Publisher Priority of the last actual Object written.
Implementations§
Source§impl FetchObjectWriter
impl FetchObjectWriter
Sourcepub fn new(group_order: GroupOrder) -> Self
pub fn new(group_order: GroupOrder) -> Self
A writer for a stream whose Groups are being written in group_order,
which has to be the order the FETCH was opened with.
Sourcepub fn header_for(
&self,
frame: &FetchObject,
) -> Result<FetchObjectHeader, CodecError>
pub fn header_for( &self, frame: &FetchObject, ) -> Result<FetchObjectHeader, CodecError>
The header that encodes frame against everything written so far.
Does not advance the writer.
Sourcefn range_fields(
&self,
frame: &FetchObject,
) -> Result<(VarInt, VarInt), CodecError>
fn range_fields( &self, frame: &FetchObject, ) -> Result<(VarInt, VarInt), CodecError>
An End of Range indicator’s two fields against this predecessor, Section 11.4.2.1.
Sourcefn identity_fields(
&self,
frame: &FetchObject,
original: &FetchObjectHeader,
) -> Result<(Option<VarInt>, Option<VarInt>), CodecError>
fn identity_fields( &self, frame: &FetchObject, original: &FetchObjectHeader, ) -> Result<(Option<VarInt>, Option<VarInt>), CodecError>
An Object’s Group ID Delta and Object ID Delta fields against this predecessor, Section 11.4.1.1.
Sourcefn subgroup_field(
&self,
frame: &FetchObject,
original: &FetchObjectHeader,
) -> Result<(u64, Option<VarInt>), CodecError>
fn subgroup_field( &self, frame: &FetchObject, original: &FetchObjectHeader, ) -> Result<(u64, Option<VarInt>), CodecError>
The Subgroup ID mode bits and the explicit field, if one is needed. The frame’s own mode is tried first.
Sourcefn priority_field(
&self,
frame: &FetchObject,
original: &FetchObjectHeader,
) -> Result<Option<u8>, CodecError>
fn priority_field( &self, frame: &FetchObject, original: &FetchObjectHeader, ) -> Result<Option<u8>, CodecError>
The Publisher Priority field, or None when the predecessor already
carries it.
Sourcepub fn write_object_header(
&mut self,
frame: &FetchObject,
out: &mut impl BufMut,
) -> Result<FetchObjectHeader, CodecError>
pub fn write_object_header( &mut self, frame: &FetchObject, out: &mut impl BufMut, ) -> Result<FetchObjectHeader, CodecError>
Encode frame against everything written so far and advance. Writes
the header only; the writer is left untouched on an error.
Sourcepub fn advance(&mut self, frame: &FetchObject)
pub fn advance(&mut self, frame: &FetchObject)
Record frame as the predecessor of whatever is written next.