pub struct FixturePool { /* private fields */ }Expand description
Runtime cache of instantiated fixtures with scoped lifecycle management.
Uses lock-free DashMap for fixture values — concurrent reads never block. Each scope level (global, worker, test) has its own pool instance. Child pools inherit from parent pools for cross-scope fixture access.
Implementations§
Source§impl FixturePool
impl FixturePool
Sourcepub fn new(defs: FxHashMap<String, FixtureDef>, scope: FixtureScope) -> Self
pub fn new(defs: FxHashMap<String, FixtureDef>, scope: FixtureScope) -> Self
Create a new root fixture pool.
Sourcepub fn child(&self, scope: FixtureScope) -> Self
pub fn child(&self, scope: FixtureScope) -> Self
Create a child pool that inherits parent fixtures for cross-scope access.
Sourcepub fn child_with_defs(
&self,
defs: FxHashMap<String, FixtureDef>,
scope: FixtureScope,
) -> Self
pub fn child_with_defs( &self, defs: FxHashMap<String, FixtureDef>, scope: FixtureScope, ) -> Self
Create a child pool with additional or overridden fixture definitions.
This is the core building block for per-test fixture graphs: worker/global fixtures live in the parent pool, while test-scoped fixtures can be specialized for a single test execution without mutating shared state.
Sourcepub fn get<T: Any + Send + Sync>(
&self,
name: &str,
) -> Pin<Box<dyn Future<Output = Result<Arc<T>>> + Send>>
pub fn get<T: Any + Send + Sync>( &self, name: &str, ) -> Pin<Box<dyn Future<Output = Result<Arc<T>>> + Send>>
Get or lazily create a fixture by name.
Returns Arc<T> since fixture values are shared and not cloneable.
Resolves dependencies recursively (DAG walk).
Sourcepub fn try_get_cached<T: Any + Send + Sync>(&self, name: &str) -> Option<Arc<T>>
pub fn try_get_cached<T: Any + Send + Sync>(&self, name: &str) -> Option<Arc<T>>
Synchronously get an already-resolved fixture from the cache. Returns None if the fixture hasn’t been resolved yet. Lock-free DashMap read — no async needed. Used by NAPI lazy fixture getters to avoid redundant async resolution.
Sourcepub fn inject<T: Any + Send + Sync>(&self, name: &str, value: Arc<T>)
pub fn inject<T: Any + Send + Sync>(&self, name: &str, value: Arc<T>)
Inject a pre-created fixture value into the pool (skips setup). Lock-free DashMap insert — no async needed.
Sourcepub async fn resolve(&self, name: &str) -> Result<()>
pub async fn resolve(&self, name: &str) -> Result<()>
Resolve a fixture by name without knowing its concrete type.
Sourcepub fn auto_fixture_names_for(&self, scope: FixtureScope) -> Vec<String>
pub fn auto_fixture_names_for(&self, scope: FixtureScope) -> Vec<String>
Names of every fixture marked auto: true whose scope matches the
argument or any narrower scope (Test fixtures get included for
Test pools; Worker auto fixtures get included for Worker pools).
Walks the parent chain so worker-scope auto fixtures are visible
from a test-scope child pool.
Sourcepub async fn teardown_all(&self)
pub async fn teardown_all(&self)
Tear down all fixtures in this pool (reverse order).
Trait Implementations§
Source§impl Clone for FixturePool
impl Clone for FixturePool
Source§fn clone(&self) -> FixturePool
fn clone(&self) -> FixturePool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FixturePool
impl !RefUnwindSafe for FixturePool
impl Send for FixturePool
impl Sync for FixturePool
impl Unpin for FixturePool
impl UnsafeUnpin for FixturePool
impl !UnwindSafe for FixturePool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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