pub enum DepScope {
Shared,
PerWorker,
Cloneable,
Hosted,
HostedRpc,
}Expand description
Sharing strategy declared on a #[test_dep]. Controls how the dependency
interacts with output capturing and parallel test execution.
See book/src/design/sharing-strategy.md for the full description.
Variants§
Today’s behaviour: a single materialized instance shared by every test.
Forces single-threaded execution when output capturing is on, because
the Arc<dyn Any> cannot cross the parent/worker process boundary.
PerWorker
Each worker child materializes its own instance independently. Tests inside one worker share the instance.
Cloneable
Parent runs the constructor once and produces wire bytes; each worker
reconstructs a local instance from those bytes via the registered
worker reconstructor (worker_fn).
Hosted
Owner runs once in the parent test runner process and stays alive
for the entire suite. The parent produces a descriptor (via
HostedDep::descriptor) and ships those descriptor bytes to every
worker. Each worker reconstructs a handle via
HostedDep::from_descriptor. The owner is held in the parent
process so singleton services (TCP listeners, Docker containers,
gRPC server clients, env-based runtimes) are not duplicated per
worker.
HostedRpc
Like Self::Hosted, but the owner stays in the parent AND workers
talk back to it via the runtime’s built-in RPC layer instead of reaching
out via their own transport. The dep implementor provides a
HostedRpcDep impl (sync owners) — or, under the tokio feature,
an AsyncHostedRpcDep impl (async owners) — on the owner type
with a stub type, a method dispatch function, and a stub builder.
Implementations§
Source§impl DepScope
impl DepScope
Sourcepub fn requires_single_thread_when_capturing(&self) -> bool
pub fn requires_single_thread_when_capturing(&self) -> bool
Returns true for scopes that materialize in the parent process and
therefore force single-threaded fallback when capturing is on.
Sourcepub fn parent_must_materialize_under_spawn_workers(&self) -> bool
pub fn parent_must_materialize_under_spawn_workers(&self) -> bool
Returns true for scopes the parent should still materialize even
when it is otherwise delegating dependency construction to workers
(i.e. skip_creating_dependencies is set). Cloneable deps need the
parent to compute the wire form; Hosted / HostedRpc deps need
the parent to hold the owner alive for the whole suite.
Trait Implementations§
impl Copy for DepScope
impl Eq for DepScope
impl StructuralPartialEq for DepScope
Auto Trait Implementations§
impl Freeze for DepScope
impl RefUnwindSafe for DepScope
impl Send for DepScope
impl Sync for DepScope
impl Unpin for DepScope
impl UnsafeUnpin for DepScope
impl UnwindSafe for DepScope
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.