Skip to main content

Providers

Trait Providers 

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

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

Bundle of all provider types for a runtime environment.

This trait consolidates the five provider types (NetworkProvider, TimeProvider, TaskProvider, RandomProvider, StorageProvider) 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

Network provider type for TCP connections and listeners.

Source

type Time: TimeProvider

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

Source

type Task: TaskProvider

Task provider type for spawning local tasks.

Source

type Random: RandomProvider

Random provider type for deterministic or real randomness.

Source

type Storage: StorageProvider

Storage provider type for file I/O operations.

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.

Source

fn storage(&self) -> &Self::Storage

Get the storage provider instance.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§