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.

Writes this segment to an IO Write instance, returning the number of bytes written

Errors

Will pass through any underlying IO errors

Constructs a new segment from some borrowed data

Gets a reference to the inner data

Copies a Segment from the provided IO Read

Errors

This will return Err(Error::SegmentIo) 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

Constructs a new segment from some data

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Encode a CipherText in binary form as a segment.

This will encode:

  • The compressed flag - 0_u8 being false and 1_u8 being true
  • The rest of the fields as a concatenation of their bytes

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Attempt to decode a Segment as a CipherText.

Errors
  • Error::SegmentLength if there is a length mismatch
  • Error::InvalidCompression if the compression flag is invalid

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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