Struct zng_layout::unit::ByteLength

source ·
pub struct ByteLength(pub usize);
Expand description

A length in bytes.

The value is stored in bytes, you can use associated functions to convert from other units or you can use the ByteUnits extension methods to initialize from an integer literal.

Tuple Fields§

§0: usize

Implementations§

source§

impl ByteLength

source

pub fn bytes(&self) -> usize

Length in bytes.

This is the same as .0.

source

pub fn kibis(self) -> f64

Length in kibi-bytes.

source

pub fn kilos(self) -> f64

Length in kilo-bytes.

source

pub fn mebis(self) -> f64

Length in mebi-bytes.

source

pub fn megas(self) -> f64

Length in mega-bytes.

source

pub fn gibis(self) -> f64

Length in gibi-bytes.

source

pub fn gigas(self) -> f64

Length in giga-bytes.

source

pub fn tebis(self) -> f64

Length in tebi-bytes.

source

pub fn teras(self) -> f64

Length in tera-bytes.

source

pub const MAX: ByteLength = _

Maximum representable byte length.

source

pub const fn saturating_add(self, rhs: ByteLength) -> ByteLength

Adds the two lengths without overflowing or wrapping.

source

pub const fn saturating_sub(self, rhs: ByteLength) -> ByteLength

Subtracts the two lengths without overflowing or wrapping.

source

pub const fn saturating_mul(self, rhs: ByteLength) -> ByteLength

Multiplies the two lengths without overflowing or wrapping.

source

pub const fn wrapping_add(self, rhs: ByteLength) -> ByteLength

Adds the two lengths wrapping overflows.

source

pub const fn wrapping_sub(self, rhs: ByteLength) -> ByteLength

Subtracts the two lengths wrapping overflows.

source

pub const fn wrapping_mul(self, rhs: ByteLength) -> ByteLength

Multiplies the two lengths wrapping overflows.

source

pub const fn wrapping_div(self, rhs: ByteLength) -> ByteLength

Divides the two lengths wrapping overflows.

source

pub fn checked_add(self, rhs: ByteLength) -> Option<ByteLength>

Adds the two lengths, returns None if the sum overflows.

source

pub fn checked_sub(self, rhs: ByteLength) -> Option<ByteLength>

Subtracts the two lengths, returns None if the subtraction overflows.

source

pub fn checked_mul(self, rhs: ByteLength) -> Option<ByteLength>

Multiplies the two lengths, returns None if the sum overflows.

source

pub fn checked_div(self, rhs: ByteLength) -> Option<ByteLength>

Divides the two lengths, returns None if the subtraction overflows.

source§

impl ByteLength

Constructors

source

pub const fn from_byte(bytes: usize) -> ByteLength

From bytes.

This is the same as ByteLength(bytes).

source

pub const fn from_kibi(kibi_bytes: usize) -> ByteLength

From kibi-bytes.

1 kibi-byte equals 1024 bytes.

source

pub const fn from_kilo(kibi_bytes: usize) -> ByteLength

From kilo-bytes.

1 kilo-byte equals 1000 bytes.

source

pub const fn from_mebi(mebi_bytes: usize) -> ByteLength

From mebi-bytes.

1 mebi-byte equals 1024² bytes.

source

pub const fn from_mega(mebi_bytes: usize) -> ByteLength

From mega-bytes.

1 mega-byte equals 1000² bytes.

source

pub const fn from_gibi(gibi_bytes: usize) -> ByteLength

From gibi-bytes.

1 gibi-byte equals 1024³ bytes.

source

pub const fn from_giga(giga_bytes: usize) -> ByteLength

From giga-bytes.

1 giga-byte equals 1000³ bytes.

source

pub const fn from_tebi(gibi_bytes: usize) -> ByteLength

From tebi-bytes.

1 tebi-byte equals 1024^4 bytes.

source

pub const fn from_tera(tera_bytes: usize) -> ByteLength

From tera-bytes.

1 tera-byte equals 1000^4 bytes.

source§

impl ByteLength

source

pub fn max(self, other: ByteLength) -> ByteLength

Compares and returns the maximum of two lengths.

source

pub fn min(self, other: ByteLength) -> ByteLength

Compares and returns the minimum of two lengths.

Trait Implementations§

source§

impl Add for ByteLength

source§

type Output = ByteLength

The resulting type after applying the + operator.
source§

fn add(self, rhs: ByteLength) -> <ByteLength as Add>::Output

Performs the + operation. Read more
source§

impl AddAssign for ByteLength

source§

fn add_assign(&mut self, rhs: ByteLength)

Performs the += operation. Read more
source§

impl Clone for ByteLength

source§

fn clone(&self) -> ByteLength

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ByteLength

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for ByteLength

source§

fn default() -> ByteLength

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ByteLength

source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<ByteLength, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for ByteLength

source§

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

Formats the value using the given formatter. Read more
source§

impl<S> Div<S> for ByteLength
where S: Into<Factor>,

source§

type Output = ByteLength

The resulting type after applying the / operator.
source§

fn div(self, rhs: S) -> ByteLength

Performs the / operation. Read more
source§

impl<S> DivAssign<S> for ByteLength
where S: Into<Factor>,

source§

fn div_assign(&mut self, rhs: S)

Performs the /= operation. Read more
source§

impl From<usize> for ByteLength

source§

fn from(value: usize) -> ByteLength

Converts to this type from the input type.
source§

impl Hash for ByteLength

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<S> Mul<S> for ByteLength
where S: Into<Factor>,

source§

type Output = ByteLength

The resulting type after applying the * operator.
source§

fn mul(self, rhs: S) -> ByteLength

Performs the * operation. Read more
source§

impl<S> MulAssign<S> for ByteLength
where S: Into<Factor>,

source§

fn mul_assign(&mut self, rhs: S)

Performs the *= operation. Read more
source§

impl Ord for ByteLength

source§

fn cmp(&self, other: &ByteLength) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for ByteLength

source§

fn eq(&self, other: &ByteLength) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for ByteLength

source§

fn partial_cmp(&self, other: &ByteLength) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for ByteLength

source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Sub for ByteLength

source§

type Output = ByteLength

The resulting type after applying the - operator.
source§

fn sub(self, rhs: ByteLength) -> <ByteLength as Sub>::Output

Performs the - operation. Read more
source§

impl SubAssign for ByteLength

source§

fn sub_assign(&mut self, rhs: ByteLength)

Performs the -= operation. Read more
source§

impl Transitionable for ByteLength

source§

fn lerp(self, to: &ByteLength, step: Factor) -> ByteLength

Sample the linear interpolation from self -> to by step.
source§

impl Copy for ByteLength

source§

impl Eq for ByteLength

source§

impl StructuralPartialEq for ByteLength

Auto Trait Implementations§

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> AnyVarValue for T
where T: VarValue,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Access to dyn Any methods.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Access to mut dyn Any methods.
source§

fn clone_boxed(&self) -> Box<dyn AnyVarValue>

Clone the value.
source§

fn clone_boxed_var(&self) -> Box<dyn AnyVar>

Clone the value into a new boxed LocalVar<Self>.
source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Access to Box<dyn Any> methods.
source§

fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool

Gets if self equals other.
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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> IntoVar<T> for T
where T: VarValue,

source§

type Var = LocalVar<T>

Variable type that will wrap the T value. Read more
source§

fn into_var(self) -> <T as IntoVar<T>>::Var

Converts the source value into a var.
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> ToTxt for T
where T: ToString,

source§

fn to_txt(&self) -> Txt

Converts the given value to an owned Txt. 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> IntoValue<T> for T
where T: VarValue,

source§

impl<T> VarValue for T
where T: Debug + Clone + PartialEq + Any + Send + Sync,