pub struct Platform { /* private fields */ }Expand description
Explicit replacement for context-carried providers: the clock, UUID source and task runner.
Implementations§
Source§impl Platform
impl Platform
Sourcepub fn now(&self) -> DateTime<Utc>
pub fn now(&self) -> DateTime<Utc>
Current time from the configured TimeProvider.
Sourcepub fn new_uuid(&self) -> String
pub fn new_uuid(&self) -> String
New identifier from the configured UuidProvider.
Sourcepub async fn run_tasks(&self, tasks: Vec<BoxFuture<'static, ()>>)
pub async fn run_tasks(&self, tasks: Vec<BoxFuture<'static, ()>>)
Runs all tasks on the configured TaskRunner and waits for them.
An empty task list returns immediately without invoking the runner.
Sourcepub fn with_time(self, p: impl TimeProvider + 'static) -> Self
pub fn with_time(self, p: impl TimeProvider + 'static) -> Self
Returns this platform with its time provider replaced.
Sourcepub fn with_uuid(self, p: impl UuidProvider + 'static) -> Self
pub fn with_uuid(self, p: impl UuidProvider + 'static) -> Self
Returns this platform with its UUID provider replaced.
Sourcepub fn with_task_runner(self, r: impl TaskRunner + 'static) -> Self
pub fn with_task_runner(self, r: impl TaskRunner + 'static) -> Self
Returns this platform with its task runner replaced.
Sourcepub fn deterministic(seed: u64) -> Self
pub fn deterministic(seed: u64) -> Self
Time starts at 2000-01-01T00:00:00Z + seed seconds and advances 1 ms per call;
UUIDs are v4-formatted strings derived from a seeded counter.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Platform
impl !UnwindSafe for Platform
impl Forget for Platform
impl Freeze for Platform
impl Move for Platform
impl Send for Platform
impl Sync for Platform
impl Unpin for Platform
impl UnsafeUnpin for Platform
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