| Crates.io | moonpool-core |
| lib.rs | moonpool-core |
| version | 0.3.0 |
| created_at | 2025-12-03 15:34:39.546031+00 |
| updated_at | 2026-01-25 12:46:18.08675+00 |
| description | Core abstractions for the moonpool simulation framework |
| homepage | |
| repository | https://github.com/PierreZ/moonpool |
| max_upload_size | |
| id | 1964284 |
| size | 62,636 |
Core abstractions for the moonpool simulation framework.
The same application code runs in both simulation and production. The only difference is which provider implementations you use.
This is FoundationDB's core insight: no mocks, no stubs—real code runs in both environments. A global network pointer switches between production (real TCP via tokio) and simulation (fake connections to in-memory buffers).
Application code depends on traits, not concrete implementations:
| Trait | Purpose | Production | Simulation |
|---|---|---|---|
TimeProvider |
Sleep, timeout, now() | Wall clock | Logical time |
NetworkProvider |
Connect, listen, accept | Real TCP | Simulated TCP |
TaskProvider |
Spawn async tasks | Tokio spawn | Event-driven |
RandomProvider |
Random numbers | System RNG | Seeded RNG |
Never call tokio directly in application code.
Instead of tokio::time::sleep(), use time_provider.sleep(). This ensures your code works identically in simulation and production.
Types for endpoint addressing:
UID: 128-bit unique identifier (deterministically generated in simulation)Endpoint: Network address + token for direct addressingNetworkAddress: IP address + portWellKnownToken: Reserved tokens for system servicesApache 2.0