pub struct SuiteGuard<T>where
T: SuiteResource,{ /* private fields */ }Expand description
Guard for suite-wide shared resource
Uses OnceLock + Weak<Arc<T>> pattern to ensure:
- Resource is initialized only once
- Resource is dropped when last test completes
§Examples
use reinhardt_testkit::resource::{SuiteResource, SuiteGuard, acquire_suite};
use rstest::*;
use std::sync::{OnceLock, Mutex, Weak};
struct MySuite;
impl SuiteResource for MySuite {
fn init() -> Self { Self }
}
static SUITE: OnceLock<Mutex<Weak<MySuite>>> = OnceLock::new();
#[fixture]
fn suite() -> SuiteGuard<MySuite> {
acquire_suite(&SUITE)
}Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for SuiteGuard<T>
impl<T> RefUnwindSafe for SuiteGuard<T>where
T: RefUnwindSafe,
impl<T> Send for SuiteGuard<T>
impl<T> Sync for SuiteGuard<T>
impl<T> Unpin for SuiteGuard<T>
impl<T> UnsafeUnpin for SuiteGuard<T>
impl<T> UnwindSafe for SuiteGuard<T>where
T: RefUnwindSafe,
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 more