Struct Delay
pub struct Delay { /* private fields */ }
The delay of a frame relative to the previous one.
The ratio is reduced on construction which means equality comparisons is reliable even when
mixing different bases. Note however that there is an upper limit to the delays that can be
represented exactly when using Self::from_saturating_duration which depends on the
granularity of the interval.
use image::Delay;
let delay_10ms = Delay::from_numer_denom_ms(10, 1);
let delay_10000us = Delay::from_numer_denom_ms(10_000, 1_000);
assert_eq!(delay_10ms, delay_10000us);
Implementations
impl Delay
fn from_numer_denom_ms(numerator: u32, denominator: u32) -> SelfCreate a delay from a ratio of milliseconds.
Examples
use image::Delay; let delay_10ms = Delay::from_numer_denom_ms(10, 1);fn from_saturating_duration(duration: Duration) -> SelfConvert from a duration, clamped between 0 and an implemented defined maximum.
The maximum is at least
i32::MAXmilliseconds. It should be noted that the accuracy of the result may be relative and very large delays have a coarse resolution.Examples
use std::time::Duration; use image::Delay; let duration = Duration::from_millis(20); let delay = Delay::from_saturating_duration(duration);fn numer_denom_ms(self) -> (u32, u32)The numerator and denominator of the delay in milliseconds.
This is guaranteed to be an exact conversion if the
Delaywas previously created with thefrom_numer_denom_msconstructor.
Trait Implementations
impl Clone for Delay
fn clone(&self) -> Self
impl Copy for Delay
impl Debug for Delay
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Delay
impl PartialEq for Delay
fn eq(&self, other: &Self) -> bool
impl PartialOrd for Delay
fn partial_cmp(&self, other: &Self) -> Option<Ordering>