Skip to content
dream-net
api

Rust API

Every public type, function and constant in dream-net, and what the crate root re-exports.

[dependencies]
dream-net = "1"

The crate is dream_net. Its modules are public, and the types a host uses are also re-exported from the root, so dream_net::Server and dream_net::server::Server are the same type.

PageCoversModule
SchemaSchema, SchemaBuilder, ChannelConfig, ChannelDef, EventDef, Delivery, OverflowPolicy, Fingerprint, the schema limitsschema
Ids and sequencesEventTypeId, ChannelId, PeerId, Seq16id, sequence
ServerServer, ServerConfig, ServerEventserver
ClientClient, ClientConfig, ClientEvent, ClientStatusclient
Keys and tokensgenerate_key, generate_connect_token, Key, UserData and their sizes, from netcoderoot
TransportConfigEvery limit and timer, its default and its rule, and the datagram constantsconfig
Lifecycle and errorsDisconnectReason, Failure, ConnectionState, ConfigError, SendError, BufferTooSmall, Errorlifecycle, error
StatisticsConnectionStats, Counters, MemoryUsagestats
Connection and inboxConnection, Shared, ConnectionEvent, Inbox, Record, MessageInfoconnection, inbox
CapturesCaptureSink, CaptureWriter, CaptureReader, their records and headercapture
SimulatorPair, Link, LinkConfig, LinkCounters, Rngsim
WireLayout, PacketWriter, decode, Decoded, Malformed, and the rest of the codecwire

The root#

Re-exported from their modules:

Client, ClientConfig, ClientEvent, ClientStatus          client
TransportConfig                                          config
Connection, ConnectionEvent, Shared                      connection
BufferTooSmall, ConfigError, Error, SendError            error
ChannelId, EventTypeId, PeerId                           id
Inbox, MessageInfo, Record                               inbox
ConnectionState, DisconnectReason, Failure               lifecycle
ChannelConfig, ChannelDef, Delivery, EventDef,
    Fingerprint, OverflowPolicy, Schema, SchemaBuilder   schema
Seq16                                                    sequence
Server, ServerConfig, ServerEvent                        server
ConnectionStats, Counters, MemoryUsage                   stats

And from netcode, so a backend can mint keys and tokens with dream-net alone: CONNECT_TOKEN_BYTES, KEY_BYTES, Key, USER_DATA_BYTES, UserData, generate_connect_token and generate_key. See Keys and tokens.

The capture, sim and wire modules, and the constants in schema, config and connection, are reached through their modules.

Conventions#

  • Time is f64 seconds on the host’s monotonic clock. Every update(time) ignores a time earlier than the last.
  • Payloads are &[u8] going in and are copied before the call returns. Coming out, they are borrowed until the next poll, or copied into a buffer the caller owns.
  • Errors: misuse returns an Err, network conditions are not errors, and malformed remote input is counted and ends the connection. No remote input panics.
  • Nothing calls back into the host from update, poll or flush, except the closures a Connection is given to transmit with and a capture sink the host installed.