pub struct LeaseTiming<'lease> { /* private fields */ }Expand description
The lease clock of one lease record under one policy.
Every method takes and returns epoch milliseconds, because a deadline is a
coordinate and not an extent. LeaseTiming::remaining_at is the one
exception, and it returns the extent that is left.
Implementations§
Source§impl<'lease> LeaseTiming<'lease>
impl<'lease> LeaseTiming<'lease>
Sourcepub const fn new(lease: &'lease Lease, config: LeaseConfig) -> Self
pub const fn new(lease: &'lease Lease, config: LeaseConfig) -> Self
Binds a lease record to a policy.
Sourcepub const fn expires_at_millis(&self) -> i64
pub const fn expires_at_millis(&self) -> i64
The instant the lease expires, in milliseconds since the Unix epoch.
Sourcepub const fn is_live_at(&self, now_millis: i64) -> bool
pub const fn is_live_at(&self, now_millis: i64) -> bool
Reports whether the lease is live at now_millis.
The lease is live before its deadline and expired from the deadline on. The rank 0 challenger may challenge at exactly the deadline, so the two tests leave no gap and no overlap.
Sourcepub fn remaining_at(&self, now_millis: i64) -> Time
pub fn remaining_at(&self, now_millis: i64) -> Time
The extent that is left before the deadline, and zero after it.
Sourcepub fn renew_at_millis(&self) -> i64
pub fn renew_at_millis(&self) -> i64
The instant at which the holder should write its next renewal.
The value is the grant instant plus the renew interval. It never passes the deadline, so a holder that follows it always writes before it loses the lease.
Sourcepub fn renew_due_at(&self, now_millis: i64) -> bool
pub fn renew_due_at(&self, now_millis: i64) -> bool
Reports whether the holder should write a renewal at now_millis.
Sourcepub fn challenge_at_millis(&self, rank: usize) -> i64
pub fn challenge_at_millis(&self, rank: usize) -> i64
The instant at which a challenger of rank rank may challenge.
Rank 0 challenges at the deadline. Each later rank adds one challenge stagger. The stagger saves epoch churn and gives no safety.
Trait Implementations§
Source§impl<'lease> Clone for LeaseTiming<'lease>
impl<'lease> Clone for LeaseTiming<'lease>
Source§fn clone(&self) -> LeaseTiming<'lease>
fn clone(&self) -> LeaseTiming<'lease>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'lease> Copy for LeaseTiming<'lease>
Auto Trait Implementations§
impl<'lease> Freeze for LeaseTiming<'lease>
impl<'lease> RefUnwindSafe for LeaseTiming<'lease>
impl<'lease> Send for LeaseTiming<'lease>
impl<'lease> Sync for LeaseTiming<'lease>
impl<'lease> Unpin for LeaseTiming<'lease>
impl<'lease> UnsafeUnpin for LeaseTiming<'lease>
impl<'lease> UnwindSafe for LeaseTiming<'lease>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);