pub struct TimeControlGuard { /* private fields */ }Expand description
A guard that automatically disables time control when dropped.
This is useful for ensuring time control is properly cleaned up even if a test panics or returns early.
§Examples
ⓘ
use durable_execution_sdk_testing::TimeControlGuard;
#[tokio::test]
async fn test_with_guard() {
let _guard = TimeControlGuard::new().await.unwrap();
// Time control is now enabled
// ... run tests ...
// Time control is automatically disabled when _guard is dropped
}Implementations§
Source§impl TimeControlGuard
impl TimeControlGuard
Sourcepub async fn new() -> Result<Self, TestError>
pub async fn new() -> Result<Self, TestError>
Creates a new TimeControlGuard and enables time control.
§Errors
Returns an error if time control cannot be enabled.
§Examples
ⓘ
use durable_execution_sdk_testing::TimeControlGuard;
#[tokio::test]
async fn test_guard_creation() {
let guard = TimeControlGuard::new().await.unwrap();
assert!(TimeControl::is_enabled());
drop(guard);
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for TimeControlGuard
impl RefUnwindSafe for TimeControlGuard
impl Send for TimeControlGuard
impl Sync for TimeControlGuard
impl Unpin for TimeControlGuard
impl UnsafeUnpin for TimeControlGuard
impl UnwindSafe for TimeControlGuard
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.