Expand description
§Moonpool Transport Layer
FDB-style transport layer for the moonpool simulation framework.
This crate provides networking primitives that work identically in simulation and production environments, following FoundationDB’s NetTransport patterns.
§Architecture
┌─────────────────────────────────────────────────┐
│ Application Code │
│ Uses NetTransport + RPC │
├─────────────────────────────────────────────────┤
│ NetTransport (endpoint routing) │
│ • Multiplexes connections per endpoint │
│ • Request/response with correlation │
├─────────────────────────────────────────────────┤
│ Peer (connection management) │
│ • Automatic reconnection with backoff │
│ • Message queuing during disconnection │
├─────────────────────────────────────────────────┤
│ Wire Format (serialization) │
│ • Length-prefixed packets │
│ • CRC32C checksums │
└─────────────────────────────────────────────────┘§Components
| Component | Purpose |
|---|---|
Peer | Resilient connection with automatic reconnection |
NetTransport | Endpoint routing and connection multiplexing |
wire | Binary serialization with CRC32C checksums |
rpc | Request/response patterns with typed messaging |
§Quick Start
ⓘ
use moonpool_transport::{NetTransportBuilder, send_request};
// Build transport with network provider
let transport = NetTransportBuilder::new(network_provider, time_provider)
.build();
// Send typed request, get typed response
let response: PongMessage = send_request(&transport, endpoint, ping).await?;Re-exports§
pub use error::MessagingError;pub use peer::Peer;pub use peer::PeerConfig;pub use peer::PeerError;pub use peer::PeerMetrics;pub use peer::PeerReceiver;pub use wire::HEADER_SIZE;pub use wire::MAX_PAYLOAD_SIZE;pub use wire::PacketHeader;pub use wire::WireError;pub use wire::deserialize_packet;pub use wire::serialize_packet;pub use wire::try_deserialize_packet;pub use rpc::EndpointMap;pub use rpc::MessageReceiver;pub use rpc::NetNotifiedQueue;pub use rpc::NetTransport;pub use rpc::NetTransportBuilder;pub use rpc::ReplyError;pub use rpc::ReplyFuture;pub use rpc::ReplyPromise;pub use rpc::RequestEnvelope;pub use rpc::RequestStream;pub use rpc::RpcError;pub use rpc::method_endpoint;pub use rpc::method_uid;pub use rpc::send_request;
Modules§
- error
- Error types for transport operations. Error types for the moonpool messaging layer.
- peer
- Resilient peer connection management. Resilient peer connection management.
- rpc
- RPC layer with typed request/response patterns. FDB-style static messaging with fixed endpoints.
- wire
- Wire format with CRC32C checksums. Wire format for packet serialization.
Structs§
- Endpoint
- Endpoint = Address + Token.
- Json
Codec - JSON codec using serde_json.
- Network
Address - Network address (IPv4/IPv6 + port + flags).
- Tokio
Network Provider - Real Tokio networking implementation.
- Tokio
Providers - Production providers using Tokio runtime.
- Tokio
Random Provider - Production random provider using thread-local RNG.
- Tokio
Task Provider - Tokio-based task provider using spawn_local for single-threaded execution.
- Tokio
Time Provider - Real time provider using Tokio’s time facilities.
- UID
- 128-bit unique identifier.
Enums§
- Codec
Error - Error type for codec operations.
- Network
Address Parse Error - Error parsing a network address from string.
- Simulation
Error - Errors that can occur during simulation operations.
- Well
Known Token - Well-known endpoint tokens.
Constants§
- WELL_
KNOWN_ RESERVED_ COUNT - Number of reserved well-known token slots.
Traits§
- Message
Codec - Pluggable message serialization format.
- Network
Provider - Provider trait for creating network connections and listeners.
- Providers
- Bundle of all provider types for a runtime environment.
- Random
Provider - Provider trait for random number generation.
- Task
Provider - Provider for spawning local tasks in single-threaded context.
- TcpListener
Trait - Trait for TCP listeners that can accept connections.
- Time
Provider - Provider trait for time operations.
Type Aliases§
- Simulation
Result - A type alias for
Result<T, SimulationError>.
Attribute Macros§
- interface
- Attribute macro for FDB-style Interface pattern.