Struct libdata::flow::Speed
[−]
pub struct Speed(pub u64);
A transfer speed.
This specifies the speed of transfer in bytes per second, rounded to whole bytes per second.
Methods
impl Speed
[src]
fn compute(bytes: Bytes, time: Duration) -> Self
Computes the speed from the amount of data transfered and time it took.
This computes the speed simply as bytes
/ time
. However, it shields the caller from
bunch of technical details, like type conversions, the right units, rounding...
Note
The time
is taken as one second long if it is shorter. This is to prevent various strange
things from happening, like:
- Division by zero.
- Producing strange spikes for single-packet or very short flows (eg. it is possible to send several packets into a buffer in a very short time without the network having that actual speed).
Parameters
bytes
: The amount of bytes transferred.time
: How long it took.
Trait Implementations
impl Add for Speed
type Output = Speed
The resulting type after applying the +
operator
fn add(self, rhs: Speed) -> Speed
The method for the +
operator
impl AddAssign for Speed
fn add_assign(&mut self, rhs: Speed)
The method for the +=
operator
impl Clone for Speed
[src]
fn clone(&self) -> Speed
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Copy for Speed
[src]
impl Debug for Speed
[src]
impl Default for Speed
[src]
impl Eq for Speed
[src]
impl From<u64> for Speed
impl Hash for Speed
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Ord for Speed
[src]
fn cmp(&self, __arg_0: &Speed) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
ord_max_min
)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
ord_max_min
)Compares and returns the minimum of two values. Read more
impl PartialEq for Speed
[src]
fn eq(&self, __arg_0: &Speed) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Speed) -> bool
This method tests for !=
.
impl PartialOrd for Speed
[src]
fn partial_cmp(&self, __arg_0: &Speed) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Speed) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Speed) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Speed) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Speed) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more