pub struct CachePieceContent { /* private fields */ }Expand description
CachePieceContent represents a cache piece metadata and cache 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 CachePieceContent
CachePieceContent implements the CachePieceContent functions.
impl CachePieceContent
CachePieceContent implements the CachePieceContent functions.
Sourcepub fn new(
number: u32,
offset: u64,
length: u64,
digest: String,
parent_id: String,
traffic_type: u8,
cost: Duration,
created_at: NaiveDateTime,
) -> Self
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 CachePieceContent request.
Sourcepub fn metadata(&self) -> CachePieceMetadata
pub fn metadata(&self) -> CachePieceMetadata
metadata returns the cache piece metadata.
Sourcepub fn metadata_len(&self) -> u32
pub fn metadata_len(&self) -> u32
metadata_len returns the length of the metadata section.
Trait Implementations§
Source§impl Clone for CachePieceContent
impl Clone for CachePieceContent
Source§fn clone(&self) -> CachePieceContent
fn clone(&self) -> CachePieceContent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CachePieceContent
impl Debug for CachePieceContent
Source§impl From<CachePieceContent> for Bytes
Implement From for Bytes for conversion to a byte slice.
impl From<CachePieceContent> for Bytes
Implement From
Source§fn from(content: CachePieceContent) -> Bytes
fn from(content: CachePieceContent) -> Bytes
from converts the cache piece content request to a byte slice.
Source§impl TryFrom<Bytes> for CachePieceContent
Implement TryFrom for CachePieceContent for conversion from a byte slice.
impl TryFrom<Bytes> for CachePieceContent
Implement TryFrom
Auto Trait Implementations§
impl Freeze for CachePieceContent
impl RefUnwindSafe for CachePieceContent
impl Send for CachePieceContent
impl Sync for CachePieceContent
impl Unpin for CachePieceContent
impl UnwindSafe for CachePieceContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more