pub struct TimeFrame {
    timeline: Timeline,
    pub(crate) slot_offset: Slot,
    slot_duration: SlotDuration,
}
Expand description

Time frame which is a timeline that is configured to be split in discrete slots

Fields§

§timeline: Timeline§slot_offset: Slot§slot_duration: SlotDuration

Implementations§

source§

impl TimeFrame

source

pub fn new(timeline: Timeline, per_slot: SlotDuration) -> Self

Create a new time frame with a specific slot size


0        1        2        3        4        5
x--------x--------x--------x--------x--------x  frame ticking at per_slot

^
|
timeline
source

pub fn change_frame(&self, slot: Slot, duration_per_slot: SlotDuration) -> Self

Change time frame at a specific slot

Note this also change the beginning of this time frame, to start

0        1        2        3        4        5
x--------x--------┳--------x--------x--------x  frame ticking at SlotDuration::from_secs(9)
                  |
                  ┕---x---x---x---x---x         returned frame
                  2   3   4   5   6   7
                  ↑
                  |
                  frame.change_frame(Slot(2), SlotDuration::from_secs(4))
source

pub fn slot0(&self) -> Slot

The current slot offset

source

pub fn slot_at_precise(&self, at: &SystemTime) -> Option<SlotAndDuration>

Given a system time get the slot and associated duration leftover

source

pub fn slot_at(&self, at: &SystemTime) -> Option<Slot>

Get the slot associated with the given system time.

It returns None if the system time doesn’t represent a valid slot in this time frame, for example if the system time is before the time frame starting point.

source

pub fn slot_to_systemtime(&self, slot: Slot) -> Option<SystemTime>

Get the system time associated with a slot on a specific timeframe

Note if the slot is not supposed to be in this reference frame, then None is returned

source

pub fn slot_duration(&self) -> u64

Returns slot duration value.

Trait Implementations§

source§

impl Clone for TimeFrame

source§

fn clone(&self) -> TimeFrame

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TimeFrame

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V