pub enum Timeout {
DontBlock,
BlockUntil(Instant),
BlockIndefinitely,
}Expand description
A timeout (or lack thereof) describing how blocking operations should behave.
Variants§
DontBlock
Disallows blocking for a contended resource.
BlockUntil(Instant)
Allows blocking for a contended resource until the given time has passed.
BlockIndefinitely
Allows blocking for a contended resource indefinitely.
Implementations§
Source§impl Timeout
impl Timeout
Sourcepub fn block_for(duration: Duration) -> Self
pub fn block_for(duration: Duration) -> Self
Creates a new timeout that lasts for the provided duration, starting now.
§Example
let first_timeout = Timeout::BlockUntil(Instant::now());
let second_timeout = Timeout::block_for(Duration::from_secs(1));
assert!(first_timeout < second_timeout);Sourcepub fn block_for_millis(millis: u64) -> Self
pub fn block_for_millis(millis: u64) -> Self
Creates a new timeout that lasts for the provided number of milliseconds, starting now.
§Example
let first_timeout = Timeout::BlockUntil(Instant::now());
let second_timeout = Timeout::block_for_millis(1000);
assert!(first_timeout < second_timeout);Trait Implementations§
Source§impl Ord for Timeout
impl Ord for Timeout
Source§impl PartialOrd for Timeout
impl PartialOrd for Timeout
impl Copy for Timeout
impl Eq for Timeout
impl StructuralPartialEq for Timeout
Auto Trait Implementations§
impl Freeze for Timeout
impl RefUnwindSafe for Timeout
impl Send for Timeout
impl Sync for Timeout
impl Unpin for Timeout
impl UnwindSafe for Timeout
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