pub struct BlockTransfer {
pub transfer_id: u64,
pub cid: String,
pub peer_id: String,
pub direction: TransferDirection,
pub total_bytes: u64,
pub chunk_size: u64,
pub state: TransferState,
pub received_chunks: Vec<u32>,
pub started_at_tick: u64,
}Expand description
A single block transfer between the local node and a remote peer.
Fields§
§transfer_id: u64Unique identifier for this transfer.
cid: StringContent identifier of the block being transferred.
peer_id: StringIdentifier of the remote peer.
direction: TransferDirectionWhether this node is uploading or downloading.
total_bytes: u64Total size of the block in bytes.
chunk_size: u64Maximum bytes per chunk (default 65536).
state: TransferStateCurrent lifecycle state of the transfer.
received_chunks: Vec<u32>Indices of chunks that have been received or sent.
started_at_tick: u64Tick at which the transfer was started.
Implementations§
Source§impl BlockTransfer
impl BlockTransfer
Sourcepub fn total_chunks(&self) -> u32
pub fn total_chunks(&self) -> u32
Return the total number of chunks required for this transfer.
Uses ceiling division so that a partial last chunk is counted.
Sourcepub fn progress(&self) -> f64
pub fn progress(&self) -> f64
Return transfer progress as a fraction in [0.0, 1.0].
Returns 0.0 when the transfer is TransferState::Pending.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Return true if the transfer has reached TransferState::Completed.
Trait Implementations§
Source§impl Clone for BlockTransfer
impl Clone for BlockTransfer
Source§fn clone(&self) -> BlockTransfer
fn clone(&self) -> BlockTransfer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BlockTransfer
impl RefUnwindSafe for BlockTransfer
impl Send for BlockTransfer
impl Sync for BlockTransfer
impl Unpin for BlockTransfer
impl UnsafeUnpin for BlockTransfer
impl UnwindSafe for BlockTransfer
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more