Skip to main content

ByteSizeExt

Trait ByteSizeExt 

Source
pub trait ByteSizeExt: Sized + Copy {
    const ZERO: Self;

    // Required methods
    fn from_bytes(bytes: u64) -> Self;
    fn from_bytes_i64(bytes: i64) -> Self;
    fn from_bytes_f64(bytes: f64) -> Self;
    fn bytes_u64(self) -> u64;
    fn bytes_usize(self) -> usize;
    fn bytes_i32(self) -> i32;
    fn bytes_i64(self) -> i64;
    fn bytes_f64(self) -> f64;
}
Expand description

Byte counts: construction from raw integers, and extraction back to them.

Required Associated Constants§

Source

const ZERO: Self

No bytes.

Required Methods§

Source

fn from_bytes(bytes: u64) -> Self

A raw unsigned byte count.

Source

fn from_bytes_i64(bytes: i64) -> Self

A raw signed byte count. This keeps the sign, so it also carries a delta, for example a quota balance that has gone into deficit. This function does not interpret Kafka’s -1 “unlimited” sentinel. Use wire::opt_size_from_bytes_i64 for that.

Source

fn from_bytes_f64(bytes: f64) -> Self

A raw byte count measured as a float (a sampled or averaged size).

Source

fn bytes_u64(self) -> u64

The count as an unsigned byte total.

Source

fn bytes_usize(self) -> usize

The count as a usize, for buffer capacities and slice lengths.

Source

fn bytes_i32(self) -> i32

The count as Kafka’s int32 byte fields (max_bytes, min_bytes).

Source

fn bytes_i64(self) -> i64

The count as Kafka’s int64 byte fields (retention.bytes).

Source

fn bytes_f64(self) -> f64

The count as a float, for metrics gauges.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§