Struct snapper_box::file::segment::Segment [−][src]
pub struct Segment<'a> { /* fields omitted */ }Expand description
A data segment within a file, encoded as vector of bytes and its length.
This type has both the ability to represent owned data, for normal copying reads, as well as owned data, for zero copy.
A valid segment has a length, encoded as an 8-byte little-endian integer, and a bytewise array of data of the specified length.
Implementations
Parses and borrows a Segment from the provided data.
Errors
This will return Err(Error::SegmentLength) if
- The specified length is too big to possibly fit into memory
- There is not enough data in the slice to fill the data buffer
Provides the length, in bytes, that this value will take up if serialized. This count includes the embedded 8-byte length tag.
Writes this segment to an array of bytes, returning the number of bytes written
Errors
Will return SegmentLength if the contained data is too big to fit in the buffer.
Constructs a new segment from some borrowed data
Trait Implementations
Encode a CipherText in binary form as a segment.
This will encode:
- The
compressedflag -0_u8being false and1_u8being true - The rest of the fields as a concatenation of their bytes
Attempt to decode a Segment as a CipherText.
Errors
Error::SegmentLengthif there is a length mismatchError::InvalidCompressionif the compression flag is invalid
Auto Trait Implementations
impl<'a> RefUnwindSafe for Segment<'a>
impl<'a> UnwindSafe for Segment<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more