memory_size_type

Struct Byte

Source
pub struct Byte(/* private fields */);
Expand description

The structure for representing a specific number of bytes.

Trait Implementations§

Source§

impl Add for Byte

Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation on a byte.

§Example
use memory_size_type::Byte;

let some_bytes = Byte::from(256);
let some_more_bytes = Byte::from(256);
assert_eq!((some_bytes + some_more_bytes).to_string(), "512 bytes");
Source§

type Output = Byte

The resulting type after applying the + operator.
Source§

impl Debug for Byte

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the represented byte value using the given formatter in a programmer-facing, debugging context.

§Example
use memory_size_type::Byte;

let one_byte = Byte::from(1);
let several_bytes = Byte::from(256);

assert_eq!("1 byte", format!("{}", one_byte));
assert_eq!("256 bytes", format!("{}", several_bytes));
Source§

impl Display for Byte

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the represented byte value using the given formatter.

§Example
use memory_size_type::Byte;

let one_byte = Byte::from(1);
let several_bytes = Byte::from(256);

assert_eq!("1 byte", format!("{}", one_byte));
assert_eq!("256 bytes", format!("{}", several_bytes));
Source§

impl From<Byte> for Kibibyte

Source§

fn from(value: Byte) -> Self

Get a kibibyte representation from a Byte representation.

§Example
use memory_size_type::{Kibibyte, Byte};

let some_kibibytes = Kibibyte::from(Byte::from(256));
Source§

impl From<u64> for Byte

Source§

fn from(value: u64) -> Self

Get a byte representation from a u64 number.

§Example
use memory_size_type::Byte;

let some_bytes = Byte::from(256);

Auto Trait Implementations§

§

impl Freeze for Byte

§

impl RefUnwindSafe for Byte

§

impl Send for Byte

§

impl Sync for Byte

§

impl Unpin for Byte

§

impl UnwindSafe for Byte

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.