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

Source§

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

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

Source§

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

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

Source§

type Output = Bandwidth

The resulting type after applying the * operator.
Source§

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

Performs the * operation. 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 · 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,

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

impl PartialEq for Bandwidth

Source§

fn eq(&self, other: &Bandwidth) -> 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 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 · 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 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<'a> Sum<&'a Bandwidth> for Bandwidth

Source§

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

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

impl Sum for Bandwidth

Source§

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

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

impl Copy for Bandwidth

Source§

impl Eq for Bandwidth

Source§

impl StructuralPartialEq for Bandwidth

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<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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.