pub struct FormattedBandwidth(/* private fields */);Expand description
A wrapper type that allows you to Display a Bandwidth
Implementations§
Source§impl FormattedBandwidth
impl FormattedBandwidth
Sourcepub fn get_ref(&self) -> &Bandwidth
👎Deprecated since 0.1.4: please use core::ops::Deref instead
pub fn get_ref(&self) -> &Bandwidth
core::ops::Deref insteadReturns a reference to the Bandwidth that is being formatted.
Sourcepub fn fmt_integer(&self, f: &mut Formatter<'_>) -> Result
pub fn fmt_integer(&self, f: &mut Formatter<'_>) -> Result
Enabling the display-integer feature will display integer values only
This method is preserved for backward compatibility and custom formatting.
Sourcepub fn fmt_decimal(&self, f: &mut Formatter<'_>) -> Result
pub fn fmt_decimal(&self, f: &mut Formatter<'_>) -> Result
Disabling the display-integer feature will display decimal values
This method is preserved for custom formatting.
Methods from Deref<Target = Bandwidth>§
pub const MAX: Bandwidth
pub const ZERO: Bandwidth
Sourcepub fn is_zero(&self) -> bool
pub 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());Sourcepub fn as_gbps(&self) -> u64
pub 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
Sourcepub fn subgbps_mbps(&self) -> u32
pub 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);Sourcepub fn subgbps_kbps(&self) -> u32
pub 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);Sourcepub fn subgbps_bps(&self) -> u32
pub 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);Sourcepub fn as_mbps(&self) -> u128
pub 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);Sourcepub fn as_kbps(&self) -> u128
pub 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);Sourcepub fn as_bps(&self) -> u128
pub 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);Sourcepub fn as_gbps_f64(&self) -> f64
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);Sourcepub fn as_gbps_f32(&self) -> f32
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);Trait Implementations§
Source§impl Clone for FormattedBandwidth
impl Clone for FormattedBandwidth
Source§fn clone(&self) -> FormattedBandwidth
fn clone(&self) -> FormattedBandwidth
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more