Skip to main content

Providers

Trait Providers 

Source
pub trait Providers: Clone + 'static {
    type Network: NetworkProvider + Clone + 'static;
    type Time: TimeProvider + Clone + 'static;
    type Task: TaskProvider + Clone + 'static;
    type Random: RandomProvider + Clone + 'static;

    // Required methods
    fn network(&self) -> &Self::Network;
    fn time(&self) -> &Self::Time;
    fn task(&self) -> &Self::Task;
    fn random(&self) -> &Self::Random;
}
Expand description

Bundle of all provider types for a runtime environment.

This trait consolidates the four provider types (NetworkProvider, TimeProvider, TaskProvider, RandomProvider) into a single bundle, reducing type parameter explosion and repetitive where clauses.

§Implementations

  • TokioProviders: Production providers using real Tokio runtime
  • SimProviders (in moonpool-sim): Simulation providers for deterministic testing

§Design

The trait uses associated types to preserve type information at compile time without runtime dispatch. Accessor methods provide convenient access to individual providers while maintaining the bundle.

Required Associated Types§

Source

type Network: NetworkProvider + Clone + 'static

Network provider type for TCP connections and listeners.

Source

type Time: TimeProvider + Clone + 'static

Time provider type for sleep, timeout, and time queries.

Source

type Task: TaskProvider + Clone + 'static

Task provider type for spawning local tasks.

Source

type Random: RandomProvider + Clone + 'static

Random provider type for deterministic or real randomness.

Required Methods§

Source

fn network(&self) -> &Self::Network

Get the network provider instance.

Source

fn time(&self) -> &Self::Time

Get the time provider instance.

Source

fn task(&self) -> &Self::Task

Get the task provider instance.

Source

fn random(&self) -> &Self::Random

Get the random provider instance.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§