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