PersistentCachePieceContent

Struct PersistentCachePieceContent 

Source
pub struct PersistentCachePieceContent { /* private fields */ }
Expand description

PersistentCachePieceContent represents a persistent cache piece metadata and piece content request.

Value Format:

  • Metadata Length (4 bytes): Length of the metadata section.
  • Number (4 bytes): Piece number to download.
  • Offset (8 bytes): Byte offset in the file.
  • Length (8 bytes): Length of the piece in bytes.
  • Digest Length (4 bytes): Length of the digest field.
  • Digest (variable): CRC32 hash of the piece content.
  • Parent ID Length (4 bytes): Length of the parent task identifier.
  • Parent ID (variable): Parent task identifier.
  • Traffic Type (1 byte): Network traffic classification type.
  • Cost (8 bytes): Download cost in seconds.
  • Created At (8 bytes): Creation timestamp as Unix epoch seconds.
  • Content (variable): Piece content bytes.
-------------------------------------------------------------------------------------------------------------------------------------
| Metadata Length (4 bytes) | Number (4 bytes) |  Offset (8 bytes) |  Length (8 bytes) | Digest Length(8 bytes) | Digest (variable) |
------------------------------------------------------------------------------------------------------------------------------------------
| Parent ID Length(4 bytes) | Parent ID (variable) | Traffic Type (1 byte) | Cost (8 bytes) | Created At (8 bytes) |  Content (variable) |
------------------------------------------------------------------------------------------------------------------------------------------

Implementations§

Source§

impl PersistentCachePieceContent

PersistentCachePieceContent implements the PersistentCachePieceContent functions.

Source

pub fn new( number: u32, offset: u64, length: u64, digest: String, parent_id: String, traffic_type: u8, cost: Duration, created_at: NaiveDateTime, ) -> Self

new creates a new PersistentCachePieceContent request.

Source

pub fn metadata(&self) -> PersistentCachePieceMetadata

metadata returns the persistent cache piece metadata.

Source

pub fn metadata_len(&self) -> u32

metadata_len returns the length of the metadata section.

Source

pub fn is_empty(&self) -> bool

is_empty returns whether the persistent cache piece content request is empty.

Trait Implementations§

Source§

impl Clone for PersistentCachePieceContent

Source§

fn clone(&self) -> PersistentCachePieceContent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PersistentCachePieceContent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<PersistentCachePieceContent> for Bytes

Implement From for Bytes for conversion to a byte slice.

Source§

fn from(content: PersistentCachePieceContent) -> Bytes

from converts the persistent cache piece content request to a byte slice.

Source§

impl TryFrom<Bytes> for PersistentCachePieceContent

Implement TryFrom for PersistentCachePieceContent for conversion from a byte slice.

Source§

fn try_from(bytes: Bytes) -> Result<Self>

try_from decodes the persistent cache piece content request from the byte slice.

Source§

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V