Skip to main content

Crate moonpool_transport

Crate moonpool_transport 

Source
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

ComponentPurpose
PeerResilient connection with automatic reconnection
NetTransportEndpoint routing and connection multiplexing
wireBinary serialization with CRC32C checksums
rpcRequest/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.
JsonCodec
JSON codec using serde_json.
NetworkAddress
Network address (IPv4/IPv6 + port + flags).
TokioNetworkProvider
Real Tokio networking implementation.
TokioProviders
Production providers using Tokio runtime.
TokioRandomProvider
Production random provider using thread-local RNG.
TokioTaskProvider
Tokio-based task provider using spawn_local for single-threaded execution.
TokioTimeProvider
Real time provider using Tokio’s time facilities.
UID
128-bit unique identifier.

Enums§

CodecError
Error type for codec operations.
NetworkAddressParseError
Error parsing a network address from string.
SimulationError
Errors that can occur during simulation operations.
WellKnownToken
Well-known endpoint tokens.

Constants§

WELL_KNOWN_RESERVED_COUNT
Number of reserved well-known token slots.

Traits§

MessageCodec
Pluggable message serialization format.
NetworkProvider
Provider trait for creating network connections and listeners.
Providers
Bundle of all provider types for a runtime environment.
RandomProvider
Provider trait for random number generation.
TaskProvider
Provider for spawning local tasks in single-threaded context.
TcpListenerTrait
Trait for TCP listeners that can accept connections.
TimeProvider
Provider trait for time operations.

Type Aliases§

SimulationResult
A type alias for Result<T, SimulationError>.

Attribute Macros§

interface
Attribute macro for FDB-style Interface pattern.