pub struct PersistentPieceContent { /* private fields */ }Expand description
PersistentPieceContent represents a persistent 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 PersistentPieceContent
PersistentPieceContent implements the PersistentPieceContent functions.
impl PersistentPieceContent
PersistentPieceContent implements the PersistentPieceContent 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 PersistentPieceContent request.
Sourcepub fn metadata(&self) -> PersistentPieceMetadata
pub fn metadata(&self) -> PersistentPieceMetadata
metadata returns the persistent 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 PersistentPieceContent
impl Clone for PersistentPieceContent
Source§fn clone(&self) -> PersistentPieceContent
fn clone(&self) -> PersistentPieceContent
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 PersistentPieceContent
impl Debug for PersistentPieceContent
Source§impl From<PersistentPieceContent> for Bytes
Implement From for Bytes for conversion to a byte slice.
impl From<PersistentPieceContent> for Bytes
Implement From
Source§fn from(content: PersistentPieceContent) -> Bytes
fn from(content: PersistentPieceContent) -> Bytes
from converts the persistent piece content request to a byte slice.
Source§impl TryFrom<Bytes> for PersistentPieceContent
Implement TryFrom for PersistentPieceContent for conversion from a byte slice.
impl TryFrom<Bytes> for PersistentPieceContent
Implement TryFrom
Auto Trait Implementations§
impl Freeze for PersistentPieceContent
impl RefUnwindSafe for PersistentPieceContent
impl Send for PersistentPieceContent
impl Sync for PersistentPieceContent
impl Unpin for PersistentPieceContent
impl UnwindSafe for PersistentPieceContent
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