Skip to main content

TransferCounter

Trait TransferCounter 

Source
pub trait TransferCounter:
    Copy
    + Ord
    + Debug
    + Display {
    const ZERO: Self;

    // Required method
    fn checked_add_chunk(self, chunk_len: usize) -> Option<Self>;
}
Expand description

Integer type used to count cumulative transfer bytes.

The default counter is usize. Use u64 or u128 when a stream may legitimately contain more bytes than fit in a pointer-sized count.

Required Associated Constants§

Source

const ZERO: Self

Zero bytes.

Required Methods§

Source

fn checked_add_chunk(self, chunk_len: usize) -> Option<Self>

Add a chunk length to the current count.

Returns None when the new cumulative count cannot be represented by this counter type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TransferCounter for u64

Source§

const ZERO: Self = 0

Source§

fn checked_add_chunk(self, chunk_len: usize) -> Option<Self>

Source§

impl TransferCounter for u128

Source§

const ZERO: Self = 0

Source§

fn checked_add_chunk(self, chunk_len: usize) -> Option<Self>

Source§

impl TransferCounter for usize

Source§

const ZERO: Self = 0

Source§

fn checked_add_chunk(self, chunk_len: usize) -> Option<Self>

Implementors§