Skip to main content

Bandwidth

Struct Bandwidth 

Source
pub struct Bandwidth { /* private fields */ }
Expand description

A Bandwidth type to represent a link’s bandwidth(to describe how many bits can be sent on the link per second), typically used for network.

Each Bandwidth is composed of a whole number of gbps(gigabits per second) and a fractional part represented in bps(bits per second). The fractional part should always in the range [0, 1_000_000_000).

Bandwidths implement many common traits, including Add, Sub, and other [ops] traits. It implements Default by returning a zero-speed Bandwidth.

  • gbps = gigabits per second
  • mbps = megabits per second
  • kbps = kilobits per second
  • bps = bits per second

§Examples

use bandwidth::Bandwidth;

let five_gbps = Bandwidth::new(5, 0);
let five_gbps_and_five_bps = five_gbps + Bandwidth::new(0, 5);

assert_eq!(five_gbps_and_five_bps.as_gbps(), 5);
assert_eq!(five_gbps_and_five_bps.subgbps_bps(), 5);

let ten_mbps = Bandwidth::from_mbps(10);

Implementations§

Source§

impl Bandwidth

Source

pub const MAX: Bandwidth

The maximum bandwidth speed.

§Examples
use bandwidth::Bandwidth;

assert_eq!(Bandwidth::MAX, Bandwidth::new(u64::MAX, 1_000_000_000 - 1));
Source

pub const ZERO: Bandwidth

A zero bandwidth speed.

§Examples
use bandwidth::Bandwidth;

let bw = Bandwidth::ZERO;
assert!(bw.is_zero());
assert_eq!(bw.as_bps(), 0);
Source

pub const fn new(gbps: u64, bps: u32) -> Bandwidth

Source

pub const fn from_gbps(gbps: u64) -> Bandwidth

Creates a new Bandwidth from the specified number of gigabits per second.

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::from_gbps(5);

assert_eq!(5, Bandwidth.as_gbps());
assert_eq!(0, Bandwidth.subgbps_bps());
Source

pub const fn from_mbps(mbps: u64) -> Bandwidth

Creates a new Bandwidth from the specified number of megabits per second.

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::from_mbps(2569);

assert_eq!(2, Bandwidth.as_gbps());
assert_eq!(569_000_000, Bandwidth.subgbps_bps());
Source

pub const fn from_kbps(kbps: u64) -> Bandwidth

Creates a new Bandwidth from the specified number of kilobits per second.

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::from_kbps(1_000_002);

assert_eq!(1, Bandwidth.as_gbps());
assert_eq!(2000, Bandwidth.subgbps_bps());
Source

pub const fn from_bps(bps: u64) -> Bandwidth

Creates a new Bandwidth from the specified number of bits per second.

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::from_bps(1_000_000_123);

assert_eq!(1, Bandwidth.as_gbps());
assert_eq!(123, Bandwidth.subgbps_bps());
Source

pub const fn is_zero(&self) -> bool

Returns true if this Bandwidth has zero speed.

§Examples
use bandwidth::Bandwidth;

assert!(Bandwidth::ZERO.is_zero());
assert!(Bandwidth::new(0, 0).is_zero());
assert!(Bandwidth::from_bps(0).is_zero());
assert!(Bandwidth::from_gbps(0).is_zero());

assert!(!Bandwidth::new(1, 1).is_zero());
assert!(!Bandwidth::from_bps(1).is_zero());
assert!(!Bandwidth::from_gbps(1).is_zero());
Source

pub const fn as_gbps(&self) -> u64

Returns the number of whole gbps contained by this Bandwidth.

The returned value does not include the fractional(bps) part of the Bandwidth, which can be obtained using subgbps_bps.

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::new(5, 730023852);
assert_eq!(Bandwidth.as_gbps(), 5);

To determine the total number of gbps represented by the Bandwidth including the fractional part, use as_gbps_f64 or as_gbps_f32

Source

pub const fn subgbps_mbps(&self) -> u32

Returns the fractional part of this Bandwidth, in whole mbps.

This method does not return the speed of the Bandwidth when represented by mbps. The returned number always represents a fractional portion of a gbps (i.e., it is less than one thousand).

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::from_mbps(5432);
assert_eq!(Bandwidth.as_gbps(), 5);
assert_eq!(Bandwidth.subgbps_mbps(), 432);
Source

pub const fn subgbps_kbps(&self) -> u32

Returns the fractional part of this Bandwidth, in whole kbps.

This method does not return the speed of the Bandwidth when represented by kbps. The returned number always represents a fractional portion of a gbps (i.e., it is less than one million).

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::from_kbps(1_234_567);
assert_eq!(Bandwidth.as_gbps(), 1);
assert_eq!(Bandwidth.subgbps_kbps(), 234_567);
Source

pub const fn subgbps_bps(&self) -> u32

Returns the fractional part of this Bandwidth, in bps.

This method does not return the speed of the Bandwidth when represented by bps. The returned number always represents a fractional portion of a gbps (i.e., it is less than one billion).

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::from_mbps(5010);
assert_eq!(Bandwidth.as_gbps(), 5);
assert_eq!(Bandwidth.subgbps_bps(), 10_000_000);
Source

pub const fn as_mbps(&self) -> u128

Returns the total number of whole mbps contained by this Bandwidth.

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::new(5, 730023852);
assert_eq!(Bandwidth.as_mbps(), 5730);
Source

pub const fn as_kbps(&self) -> u128

Returns the total number of whole kbps contained by this Bandwidth.

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::new(5, 730023852);
assert_eq!(Bandwidth.as_kbps(), 5730023);
Source

pub const fn as_bps(&self) -> u128

Returns the total number of bps contained by this Bandwidth.

§Examples
use bandwidth::Bandwidth;

let Bandwidth = Bandwidth::new(5, 730023852);
assert_eq!(Bandwidth.as_bps(), 5730023852);
Source

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

Checked Bandwidth addition. Computes self + other, returning None if overflow occurred.

§Examples

Basic usage:

use bandwidth::Bandwidth;

assert_eq!(Bandwidth::new(0, 0).checked_add(Bandwidth::new(0, 1)), Some(Bandwidth::new(0, 1)));
assert_eq!(Bandwidth::new(1, 0).checked_add(Bandwidth::new(u64::MAX, 0)), None);
Source

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

Saturating Bandwidth addition. Computes self + other, returning Bandwidth::MAX if overflow occurred.

§Examples
use bandwidth::Bandwidth;

assert_eq!(Bandwidth::new(0, 0).saturating_add(Bandwidth::new(0, 1)), Bandwidth::new(0, 1));
assert_eq!(Bandwidth::new(1, 0).saturating_add(Bandwidth::new(u64::MAX, 0)), Bandwidth::MAX);
Source

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

Checked Bandwidth subtraction. Computes self - other, returning None if the result would be negative or if overflow occurred.

§Examples

Basic usage:

use bandwidth::Bandwidth;

assert_eq!(Bandwidth::new(0, 1).checked_sub(Bandwidth::new(0, 0)), Some(Bandwidth::new(0, 1)));
assert_eq!(Bandwidth::new(0, 0).checked_sub(Bandwidth::new(0, 1)), None);
Source

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

Saturating Bandwidth subtraction. Computes self - other, returning Bandwidth::ZERO if the result would be negative or if overflow occurred.

§Examples
use bandwidth::Bandwidth;

assert_eq!(Bandwidth::new(0, 1).saturating_sub(Bandwidth::new(0, 0)), Bandwidth::new(0, 1));
assert_eq!(Bandwidth::new(0, 0).saturating_sub(Bandwidth::new(0, 1)), Bandwidth::ZERO);
Source

pub const fn checked_mul(self, rhs: u32) -> Option<Bandwidth>

Checked Bandwidth multiplication. Computes self * other, returning None if overflow occurred.

§Examples

Basic usage:

use bandwidth::Bandwidth;

assert_eq!(Bandwidth::new(0, 500_000_001).checked_mul(2), Some(Bandwidth::new(1, 2)));
assert_eq!(Bandwidth::new(u64::MAX - 1, 0).checked_mul(2), None);
Source

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

Saturating Bandwidth multiplication. Computes self * other, returning Bandwidth::MAX if overflow occurred.

§Examples
use bandwidth::Bandwidth;

assert_eq!(Bandwidth::new(0, 500_000_001).saturating_mul(2), Bandwidth::new(1, 2));
assert_eq!(Bandwidth::new(u64::MAX - 1, 0).saturating_mul(2), Bandwidth::MAX);
Source

pub const fn checked_div(self, rhs: u32) -> Option<Bandwidth>

Checked Bandwidth division. Computes self / other, returning None if other == 0.

§Examples

Basic usage:

use bandwidth::Bandwidth;

assert_eq!(Bandwidth::new(2, 0).checked_div(2), Some(Bandwidth::new(1, 0)));
assert_eq!(Bandwidth::new(1, 0).checked_div(2), Some(Bandwidth::new(0, 500_000_000)));
assert_eq!(Bandwidth::new(2, 0).checked_div(0), None);
Source

pub fn as_gbps_f64(&self) -> f64

Returns the number of gbps contained by this Bandwidth as f64.

The returned value does include the fractional (bps) part of the Bandwidth.

§Examples
use bandwidth::Bandwidth;

let bw = Bandwidth::new(2, 700_000_000);
assert_eq!(bw.as_gbps_f64(), 2.7);
Source

pub fn as_gbps_f32(&self) -> f32

Returns the number of gbps contained by this Bandwidth as f32.

The returned value does include the fractional (bps) part of the Bandwidth.

§Examples
use bandwidth::Bandwidth;

let bw = Bandwidth::new(2, 700_000_000);
assert_eq!(bw.as_gbps_f32(), 2.7);
Source

pub fn from_gbps_f64(gbps: f64) -> Bandwidth

Creates a new Bandwidth from the specified number of gbps represented as f64.

§Panics

This constructor will panic if gbps is negative, overflows Bandwidth or not finite.

§Examples
use bandwidth::Bandwidth;

let res = Bandwidth::from_gbps_f64(0.0);
assert_eq!(res, Bandwidth::new(0, 0));
let res = Bandwidth::from_gbps_f64(1e-20);
assert_eq!(res, Bandwidth::new(0, 0));
let res = Bandwidth::from_gbps_f64(4.2e-7);
assert_eq!(res, Bandwidth::new(0, 420));
let res = Bandwidth::from_gbps_f64(2.7);
assert_eq!(res, Bandwidth::new(2, 700_000_000));
let res = Bandwidth::from_gbps_f64(3e10);
assert_eq!(res, Bandwidth::new(30_000_000_000, 0));
// subnormal float
let res = Bandwidth::from_gbps_f64(f64::from_bits(1));
assert_eq!(res, Bandwidth::new(0, 0));
// conversion uses rounding
let res = Bandwidth::from_gbps_f64(0.999e-9);
assert_eq!(res, Bandwidth::new(0, 1));
Source

pub fn from_gbps_f32(gbps: f32) -> Bandwidth

Creates a new Bandwidth from the specified number of gbps represented as f32.

§Panics

This constructor will panic if gbps is negative, overflows Bandwidth or not finite.

§Examples
use bandwidth::Bandwidth;

let res = Bandwidth::from_gbps_f32(0.0);
assert_eq!(res, Bandwidth::new(0, 0));
let res = Bandwidth::from_gbps_f32(1e-20);
assert_eq!(res, Bandwidth::new(0, 0));
let res = Bandwidth::from_gbps_f32(4.2e-7);
assert_eq!(res, Bandwidth::new(0, 420));
let res = Bandwidth::from_gbps_f32(2.7);
assert_eq!(res, Bandwidth::new(2, 700_000_048));
let res = Bandwidth::from_gbps_f32(3e10);
assert_eq!(res, Bandwidth::new(30_000_001_024, 0));
// subnormal float
let res = Bandwidth::from_gbps_f32(f32::from_bits(1));
assert_eq!(res, Bandwidth::new(0, 0));
// conversion uses rounding
let res = Bandwidth::from_gbps_f32(0.999e-9);
assert_eq!(res, Bandwidth::new(0, 1));
Source

pub fn mul_f64(self, rhs: f64) -> Bandwidth

Multiplies Bandwidth by f64.

§Panics

This method will panic if result is negative, overflows Bandwidth or not finite.

§Examples
use bandwidth::Bandwidth;

let bw = Bandwidth::new(2, 700_000_000);
assert_eq!(bw.mul_f64(3.14), Bandwidth::new(8, 478_000_000));
assert_eq!(bw.mul_f64(3.14e5), Bandwidth::new(847_800, 0));
Source

pub fn mul_f32(self, rhs: f32) -> Bandwidth

Multiplies Bandwidth by f32.

§Panics

This method will panic if result is negative, overflows Bandwidth or not finite.

§Examples
use bandwidth::Bandwidth;

let bw = Bandwidth::new(2, 700_000_000);
assert_eq!(bw.mul_f32(3.14), Bandwidth::new(8, 478_000_641));
assert_eq!(bw.mul_f32(3.14e5), Bandwidth::new(847800, 0));
Source

pub fn div_f64(self, rhs: f64) -> Bandwidth

Divide Bandwidth by f64.

§Panics

This method will panic if result is negative, overflows Bandwidth or not finite.

§Examples
use bandwidth::Bandwidth;

let bw = Bandwidth::new(2, 700_000_000);
assert_eq!(bw.div_f64(3.14), Bandwidth::new(0, 859_872_611));
assert_eq!(bw.div_f64(3.14e5), Bandwidth::new(0, 8_599));
Source

pub fn div_f32(self, rhs: f32) -> Bandwidth

Divide Bandwidth by f32.

§Panics

This method will panic if result is negative, overflows Bandwidth or not finite.

§Examples
use bandwidth::Bandwidth;

let bw = Bandwidth::new(2, 700_000_000);
// note that due to rounding errors result is slightly
// different from 0.859_872_611
assert_eq!(bw.div_f32(3.14), Bandwidth::new(0, 859_872_580));
assert_eq!(bw.div_f32(3.14e5), Bandwidth::new(0, 8_599));
Source

pub fn div_bandwidth_f64(self, rhs: Bandwidth) -> f64

Divide Bandwidth by Bandwidth and return f64.

§Examples
use bandwidth::Bandwidth;

let bw1 = Bandwidth::new(2, 700_000_000);
let bw2 = Bandwidth::new(5, 400_000_000);
assert_eq!(bw1.div_bandwidth_f64(bw2), 0.5);
Source

pub fn div_bandwidth_f32(self, rhs: Bandwidth) -> f32

Divide Bandwidth by Bandwidth and return f32.

§Examples
use bandwidth::Bandwidth;

let bw1 = Bandwidth::new(2, 700_000_000);
let bw2 = Bandwidth::new(5, 400_000_000);
assert_eq!(bw1.div_bandwidth_f32(bw2), 0.5);
Source§

impl Bandwidth

Source

pub fn try_from_gbps_f32(gbps: f32) -> Result<Bandwidth, TryFromFloatGbpsError>

The checked version of from_gbps_f32.

This constructor will return an Err if gbps is negative, overflows Bandwidth or not finite.

§Examples
use bandwidth::Bandwidth;

let res = Bandwidth::try_from_gbps_f32(0.0);
assert_eq!(res, Ok(Bandwidth::new(0, 0)));
let res = Bandwidth::try_from_gbps_f32(1e-20);
assert_eq!(res, Ok(Bandwidth::new(0, 0)));
let res = Bandwidth::try_from_gbps_f32(4.2e-7);
assert_eq!(res, Ok(Bandwidth::new(0, 420)));
let res = Bandwidth::try_from_gbps_f32(2.7);
assert_eq!(res, Ok(Bandwidth::new(2, 700_000_048)));
let res = Bandwidth::try_from_gbps_f32(3e10);
assert_eq!(res, Ok(Bandwidth::new(30_000_001_024, 0)));
// subnormal float:
let res = Bandwidth::try_from_gbps_f32(f32::from_bits(1));
assert_eq!(res, Ok(Bandwidth::new(0, 0)));

let res = Bandwidth::try_from_gbps_f32(-5.0);
assert!(res.is_err());
let res = Bandwidth::try_from_gbps_f32(f32::NAN);
assert!(res.is_err());
let res = Bandwidth::try_from_gbps_f32(2e19);
assert!(res.is_err());

// the conversion uses rounding with tie resolution to even
let res = Bandwidth::try_from_gbps_f32(0.999e-9);
assert_eq!(res, Ok(Bandwidth::new(0, 1)));

// this float represents exactly 976562.5e-9
let val = f32::from_bits(0x3A80_0000);
let res = Bandwidth::try_from_gbps_f32(val);
assert_eq!(res, Ok(Bandwidth::new(0, 976_562)));

// this float represents exactly 2929687.5e-9
let val = f32::from_bits(0x3B40_0000);
let res = Bandwidth::try_from_gbps_f32(val);
assert_eq!(res, Ok(Bandwidth::new(0, 2_929_688)));

// this float represents exactly 1.000_976_562_5
let val = f32::from_bits(0x3F802000);
let res = Bandwidth::try_from_gbps_f32(val);
assert_eq!(res, Ok(Bandwidth::new(1, 976_562)));

// this float represents exactly 1.002_929_687_5
let val = f32::from_bits(0x3F806000);
let res = Bandwidth::try_from_gbps_f32(val);
assert_eq!(res, Ok(Bandwidth::new(1, 2_929_688)));
Source

pub fn try_from_gbps_f64(gbps: f64) -> Result<Bandwidth, TryFromFloatGbpsError>

The checked version of from_gbps_f64.

This constructor will return an Err if secs is negative, overflows Bandwidth or not finite.

§Examples
use bandwidth::Bandwidth;

let res = Bandwidth::try_from_gbps_f64(0.0);
assert_eq!(res, Ok(Bandwidth::new(0, 0)));
let res = Bandwidth::try_from_gbps_f64(1e-20);
assert_eq!(res, Ok(Bandwidth::new(0, 0)));
let res = Bandwidth::try_from_gbps_f64(4.2e-7);
assert_eq!(res, Ok(Bandwidth::new(0, 420)));
let res = Bandwidth::try_from_gbps_f64(2.7);
assert_eq!(res, Ok(Bandwidth::new(2, 700_000_000)));
let res = Bandwidth::try_from_gbps_f64(3e10);
assert_eq!(res, Ok(Bandwidth::new(30_000_000_000, 0)));
// subnormal float
let res = Bandwidth::try_from_gbps_f64(f64::from_bits(1));
assert_eq!(res, Ok(Bandwidth::new(0, 0)));

let res = Bandwidth::try_from_gbps_f64(-5.0);
assert!(res.is_err());
let res = Bandwidth::try_from_gbps_f64(f64::NAN);
assert!(res.is_err());
let res = Bandwidth::try_from_gbps_f64(2e19);
assert!(res.is_err());

// the conversion uses rounding with tie resolution to even
let res = Bandwidth::try_from_gbps_f64(0.999e-9);
assert_eq!(res, Ok(Bandwidth::new(0, 1)));
let res = Bandwidth::try_from_gbps_f64(0.999_999_999_499);
assert_eq!(res, Ok(Bandwidth::new(0, 999_999_999)));
let res = Bandwidth::try_from_gbps_f64(0.999_999_999_501);
assert_eq!(res, Ok(Bandwidth::new(1, 0)));
let res = Bandwidth::try_from_gbps_f64(42.999_999_999_499);
assert_eq!(res, Ok(Bandwidth::new(42, 999_999_999)));
let res = Bandwidth::try_from_gbps_f64(42.999_999_999_501);
assert_eq!(res, Ok(Bandwidth::new(43, 0)));

// this float represents exactly 976562.5e-9
let val = f64::from_bits(0x3F50_0000_0000_0000);
let res = Bandwidth::try_from_gbps_f64(val);
assert_eq!(res, Ok(Bandwidth::new(0, 976_562)));

// this float represents exactly 2929687.5e-9
let val = f64::from_bits(0x3F68_0000_0000_0000);
let res = Bandwidth::try_from_gbps_f64(val);
assert_eq!(res, Ok(Bandwidth::new(0, 2_929_688)));

// this float represents exactly 1.000_976_562_5
let val = f64::from_bits(0x3FF0_0400_0000_0000);
let res = Bandwidth::try_from_gbps_f64(val);
assert_eq!(res, Ok(Bandwidth::new(1, 976_562)));

// this float represents exactly 1.002_929_687_5
let val = f64::from_bits(0x3_FF00_C000_0000_000);
let res = Bandwidth::try_from_gbps_f64(val);
assert_eq!(res, Ok(Bandwidth::new(1, 2_929_688)));

Trait Implementations§

Source§

impl Add for Bandwidth

Source§

type Output = Bandwidth

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Bandwidth) -> Bandwidth

Performs the + operation. Read more
Source§

impl AddAssign for Bandwidth

Source§

fn add_assign(&mut self, rhs: Bandwidth)

Performs the += operation. Read more
Source§

impl Clone for Bandwidth

Source§

fn clone(&self) -> Bandwidth

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Bandwidth

Source§

impl Debug for Bandwidth

Source§

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

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

impl Default for Bandwidth

Source§

fn default() -> Bandwidth

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

impl<'de> Deserialize<'de> for Bandwidth

Source§

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

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

impl Div<u32> for Bandwidth

Source§

type Output = Bandwidth

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u32) -> Bandwidth

Performs the / operation. Read more
Source§

impl DivAssign<u32> for Bandwidth

Source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
Source§

impl Eq for Bandwidth

Source§

impl Hash for Bandwidth

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 Mul<u32> for Bandwidth

Source§

type Output = Bandwidth

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u32) -> Bandwidth

Performs the * operation. Read more
Source§

impl MulAssign<u32> for Bandwidth

Source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
Source§

impl Ord for Bandwidth

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

impl PartialEq for Bandwidth

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Bandwidth

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 Bandwidth

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 StructuralPartialEq for Bandwidth

Source§

impl Sub for Bandwidth

Source§

type Output = Bandwidth

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Bandwidth) -> Bandwidth

Performs the - operation. Read more
Source§

impl SubAssign for Bandwidth

Source§

fn sub_assign(&mut self, rhs: Bandwidth)

Performs the -= operation. Read more
Source§

impl Sum for Bandwidth

Source§

fn sum<I>(iter: I) -> Bandwidth
where I: Iterator<Item = Bandwidth>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a> Sum<&'a Bandwidth> for Bandwidth

Source§

fn sum<I>(iter: I) -> Bandwidth
where I: Iterator<Item = &'a Bandwidth>,

Takes an iterator and generates Self from the elements by “summing up” the items.

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

Source§

impl<T, Right> ClosedAddAssign<Right> for T
where T: ClosedAdd<Right> + AddAssign<Right>,

Source§

impl<T, Right> ClosedDiv<Right> for T
where T: Div<Right, Output = T> + DivAssign<Right>,

Source§

impl<T, Right> ClosedDivAssign<Right> for T
where T: ClosedDiv<Right> + DivAssign<Right>,

Source§

impl<T, Right> ClosedMul<Right> for T
where T: Mul<Right, Output = T> + MulAssign<Right>,

Source§

impl<T, Right> ClosedMulAssign<Right> for T
where T: ClosedMul<Right> + MulAssign<Right>,

Source§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

Source§

impl<T, Right> ClosedSubAssign<Right> for T
where T: ClosedSub<Right> + SubAssign<Right>,

Source§

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

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V