pub struct IndexConversion { /* private fields */ }Expand description
Result of converting an Instant to a ClockIndex, paired with any
diagnostics raised by the conversion.
A conversion is exact when the instant lands on a clock boundary; otherwise the index is rounded toward zero and a warning diagnostic records that the instant was not on an exact boundary.
§Examples
use sim_kernel::Symbol;
use sim_lib_stream_clock::{Clock, Instant};
let clock = Clock::frame(Symbol::new("audio"), 48_000)?;
let conversion = clock.index_for_instant(Instant::seconds(1))?;
assert_eq!(conversion.index().value(), 48_000);
assert!(conversion.is_exact());Implementations§
Source§impl IndexConversion
impl IndexConversion
Sourcepub fn index(&self) -> ClockIndex
pub fn index(&self) -> ClockIndex
Returns the converted index.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Returns the diagnostics raised by the conversion, empty when exact.
Trait Implementations§
Source§impl Clone for IndexConversion
impl Clone for IndexConversion
Source§fn clone(&self) -> IndexConversion
fn clone(&self) -> IndexConversion
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IndexConversion
impl Debug for IndexConversion
impl Eq for IndexConversion
Source§impl PartialEq for IndexConversion
impl PartialEq for IndexConversion
Source§fn eq(&self, other: &IndexConversion) -> bool
fn eq(&self, other: &IndexConversion) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for IndexConversion
Auto Trait Implementations§
impl Freeze for IndexConversion
impl RefUnwindSafe for IndexConversion
impl Send for IndexConversion
impl Sync for IndexConversion
impl Unpin for IndexConversion
impl UnsafeUnpin for IndexConversion
impl UnwindSafe for IndexConversion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more