Skip to main content

Crate weida

Crate weida 

Source
Expand description

weida: a QUIC-native messaging framework.

This crate hosts the runtime, the native QUIC transport, the raw stream core and the brokerless messaging patterns: Req/Rep, Push/Pull, Pub/Sub, PAIR, SURVEY and BUS — the whole nanomsg set, none of which adds wire vocabulary. A completion is a cursor: a level plus an absolute byte offset, reported on a unidirectional stream of its own (Cursors, Reporter). docs/ARCHITECTURE.md describes the layer model, docs/PROTOCOL.md is the normative wire specification, and docs/FAILURE_MODEL.md defines what each outcome means.

use weida::{Runtime, RuntimeConfig, TransferMeta, Trust};

let runtime = Runtime::new(RuntimeConfig::default())?;

// Trust belongs to the dialling endpoint, not to the runtime. Here the
// address itself names the peer's public key, so nothing else is needed.
let requester = runtime.requester(Trust::by_address());
requester
    .connect("weida://sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08@127.0.0.1:7443/transform")
    .await?;

// One bidirectional stream: the request half and the reply half. The
// stream is the correlation, so nothing on the wire names the exchange.
let (mut transfer, reply) = requester.open(TransferMeta::default()).await?;
transfer.write_all(b"hello weida").await?;
transfer.finish()?;

let body = reply.recv().await?.collect(64 * 1024).await?;
println!("{}", String::from_utf8_lossy(&body));

The example above runs on the caller’s ambient Tokio reactor. A caller that has none — or whose executor is not Tokio at all — uses Runtime::owned instead: the runtime then owns the reactor quinn needs, and every task, timer and name lookup weida performs runs there, while the futures it hands back may be driven by any executor. Transfer payloads implement both the tokio::io and the futures-io traits for the same reason.

Modules§

codes
QUIC application error codes used in CONNECTION_CLOSE, RESET_STREAM and STOP_SENDING (docs/PROTOCOL.md §7).
filter
The topic filter grammar of docs/PROTOCOL.md §6.4.

Structs§

Acceptor
The bound side of the stream core.
Binding
One concrete transport binding of a Listener.
ClientTls
TLS configuration of a dialling endpoint: what it trusts and, optionally, who it is.
ConnectionId
Identifies one connection of this process.
ConnectionStats
One live connection of a dialling handle, labelled by the address the application dialled (0036 §4.1).
Consumer
One subscribed consumer, and the way to deliver to it.
ConsumerId
Identifies one consuming connection on one path.
CreditGrant
A consumer’s absolute delivery limit for one subscription.
CursorSet
The latest offset reported per level, for one transfer.
Cursors
The reader’s end of one transfer’s report.
Delivery
The transport receipt for a finished transfer.
DishDrops
What a radio dropped toward one joined dish connection, summed over topics (decisions/0037 §4.6).
Drained
What a drain achieved, counted locally.
Endpoint
A typed messaging endpoint.
EndpointAddr
A parsed weida://[fingerprint@]host[:port]/path address.
FanOut
A publish in progress: a payload written once and fanned out to one stream per subscriber, without ever being held whole.
FilesOptions
How a file source watches its directory.
Fingerprint
SHA-256 digest of a peer’s public key.
Flow
The sending half of one datagram flow.
FlowInfo
What the receiver learns about a flow when it arrives.
FlowMeta
What a sender attaches to a flow, once, when it registers it.
FlowStats
Counters of one flow, on the side that holds it.
Gap
What a receiver observed about one transfer’s place in its producer’s sequence.
GuaranteeSet
One level per guarantee dimension, as declared in HELLO keys 5 and 6 (docs/PROTOCOL.md §6.5).
Handoff
What Binding::hand_over leaves for the successor: the bound socket and the close packets held for its clients (decisions/0039).
Identity
Who this endpoint is: a certificate chain and the private key behind it.
IdentityEvents
The event stream of one IdentitySource or TrustSource.
IdentitySource
Where an identity comes from, and the identity of the moment.
IncomingFlow
The receiving half of one datagram flow.
IncomingMeta
Metadata of an inbound transfer.
IncomingRequest
A request accepted by a crate::Replier or a raw crate::Acceptor.
IncomingTransfer
An inbound transfer: one receive stream plus the metadata that described it.
InprocAddr
A parsed weida+inproc://<bus>/<path> address.
Join
A dish’s request to join a filter, as a radio’s admission sees it (Radio::with_admission, decisions/0035 §4.3).
JoinTerms
What a dish asks for when it joins a filter (decisions/0037 §4.3).
Limits
Resource limits applied to one connection.
Listener
One externally reachable messaging namespace.
LocalBinding
One in-process binding: a bus name and nothing else.
LocalPrincipal
A principal the kernel proved, on a local transport.
Network
Where a runtime’s QUIC sockets live: the operating system’s UDP (the default) or, with the cargo feature test-util, a SimNet shared by the runtimes of one test. On a SimNet a weida+unix binding and dial are simulated too (by path, with no socket file); weida+inproc and weida+pipe are not affected.
OutgoingTransfer
An outgoing transfer: one QUIC send stream, owned outright.
PathStats
What the path under a connection looks like now — what a jitter buffer or a bitrate controller sizes itself by.
Peer
The dialling side of the stream core.
PeerChain
The certificate chain a peer presented in the TLS handshake: DER, leaf first, as it arrived. weida parsed only the leaf’s public key, whose fingerprint is the peer; what the rest certifies is the application’s to read (decisions/0035 §4.2).
PeerEvents
The event stream of one dialling endpoint.
PipeAddr
A parsed weida+pipe://<pipe-name>/<path> address.
ReconnectPolicy
How a dialling endpoint redials an address it has lost.
Relay
The relay a crate::Listener serves on RELAY_PATH.
RelayAddr
A parsed weida+relay://<peer>@[relay-key@]host[:port]/path address: the endpoint path of the peer whose key is target, which serves through the relay at relay.
RelayBudget
What one tunnel may move through a Relay, both directions together: bytes_per_sec, with a burst of one second’s bytes. A datagram past it is dropped, as a link at that rate drops, and the tunnel’s QUIC backs off. Zero counts as one; a budget below one full-size datagram per second (about 1500 bytes) carries no full-size datagram.
RelayRequest
A registration or a tunnel asking a Relay to be served.
RemoteStats
The peer’s view of the path under a connection, from its latest REPORT record (decisions/0036 §4.5).
ReplyStream
The reply half of an exchange the requester is waiting on.
Reporter
The writer’s end: what a receiver uses to report on a transfer it got.
Runtime
A process-level execution and resource container.
RuntimeConfig
Configuration for one crate::Runtime.
Segment
One segment, open on every receiver it was opened toward.
SegmentTerms
How a segment is sent: what the sender decides for every copy of it (decisions/0037 §4.2).
ServerTls
TLS configuration of a binding: who it is and, optionally, whom it lets in.
SharedResolver
The resolver a configuration holds.
SurveyRun
One survey in progress: the answers, and what the deadline cost.
SystemResolver
The system resolver: an IP literal in place, everything else through getaddrinfo.
TopicDrops
What a publisher dropped on one topic, by cause.
TraceContext
A W3C Trace Context traceparent.
TransferMeta
Per-transfer metadata supplied by the application.
TransportStats
The transport’s view of one QUIC connection: its path and its traffic in both directions.
Trust
Whom a peer is accepted as.
TrustSource
Whom a peer is accepted as, as a source: the anchors and pins of the moment, changeable under a live binding.
UdpCounts
UDP datagrams and the bytes inside them, in one direction of one connection. Every QUIC packet travels in one, so this counts all of a connection’s traffic, not one flow’s payload.
UnixAddr
A parsed weida+unix://<percent-encoded-socket-path>/<path> address.
UnixBinding
One AF_UNIX binding: the socket file, removed when this drops; or, under Network::sim, the simulated path, freed when this drops.
WeakIdentitySource
A handle to an IdentitySource that does not keep it alive.
WeakTrustSource
A handle to a TrustSource that does not keep it alive.
WindowsPrincipal
A principal the kernel proved, on a Windows named pipe.

Enums§

Acknowledgement
Acknowledgement/completion dimension. A ladder; the durability axes of Durability and replicas are not part of it.
Address
An address of any transport.
Alpn
The TLS ALPN token a binding offers or a dial asks for.
Backpressure
Backpressure dimension. Not ordered: these are behaviours, not strengths, so two peers state the same one or fail to negotiate.
Bus
A member of a BUS.
Cast
The sending side of RADIO/DISH: lossy fan-out of segments (decisions/0034 §4.6).
ClientTrust
Whom a binding lets in when it requires clients to present a key.
Congestion
A QUIC congestion controller, as quinn implements them.
CursorLevel
A level a cursor can name: one weida defines, or one the application does.
Deduplication
Deduplication dimension. A ladder: later is stronger.
DeliveryLevel
Delivery dimension (GUARANTEES.md §3). A ladder: later is stronger.
Discovery
Whether a dialled authority may name a set of nodes.
Durability
Persistence axis of Stored/Replicated (decisions/0004 §4.1).
Error
Everything that can go wrong in a weida operation.
ErrorCode
Wire codes carried in an ERROR frame (docs/PROTOCOL.md §6.4).
GiveUp
Why a slot stopped redialling.
IdentityEvent
One transition of an IdentitySource.
Incoming
One inbound thing on a raw acceptor’s path, whichever kind the peer sent.
LossCause
Why a connection is gone.
OrderingMode
Ordering dimension. A ladder: later is stronger.
OutboxFull
What a send does when the outbox is at its bound (crate::RuntimeConfig::outbox_messages).
Pair
Either side of PAIR: one connection, one peer, both directions.
PeerEvent
One transition of one dialled address, reported on PeerEvents.
PeerIdentity
Who the peer is, once it has been proved.
Pem
Where PEM material comes from.
ProducerNaming
How a producer is named for the sequence field of decisions/0001 §7.3. Not ordered: two peers state the same one or fail.
Pub
The publishing side of Pub/Sub.
Pull
The receiving side of Push/Pull.
Push
The sending side of Push/Pull.
Received
What a dish receives.
Rep
The replying side of Req/Rep.
ReportMode
How often a reporter emits a record (docs/PROTOCOL.md §6.2, key 11).
Req
The requesting side of Req/Rep.
Respond
The answering side of SURVEY.
StopReason
Why a peer refused to receive more payload, as carried by STOP_SENDING’s QUIC application error code.
Sub
The subscribing side of Pub/Sub.
Survey
The asking side of SURVEY.
Tune
The receiving side of RADIO/DISH.

Constants§

ALPN
TLS ALPN token identifying the weida native QUIC protocol.
DEFAULT_DATAGRAM_RECEIVE_BYTES
The documented Limits::datagram_receive_bytes for a profile that enables datagram flows: 64 KiB, about fifty full datagrams.
DEFAULT_PORT
The port a weida:// URL means when it writes none.
MAX_SEGMENT_LAYERS
How many layers a stream segment can carry: 0..=15, the cap of DATA key 14 (decisions/0037 §4.3).
RAFT_ALPN
TLS ALPN token of a consensus connection (weida-raft); same protocol, separate connections.
RELAY_PATH
The endpoint path a relay serves on, and the one a relayed address dials on its relay (docs/PROTOCOL.md §9.6).
SCHEME_RELAY
URL scheme of an address reached through a relay.
VERSION
Wire protocol version implemented by this crate (experimental).

Traits§

Pattern
A messaging pattern.
Resolver
What a name means.

Functions§

new_trace
Generates a fresh root trace context.

Type Aliases§

BusMember
One member of a BUS.
Dish
The receiving half of RADIO/DISH: connects, joins topics, and receives the newest segment of each.
Paired
Either half of PAIR — the pattern is symmetric, so there is one role.
Publisher
The publishing half of Pub/Sub.
Puller
The receiving half of Push/Pull.
Pusher
The sending half of Push/Pull.
Radio
The sending half of RADIO/DISH: binds, and fans segments out to every dish whose filter matches, dropping rather than waiting.
Replier
The replying half of Req/Rep.
Requester
The requesting half of Req/Rep.
Resolved
The future a Resolver returns.
Respondent
The answering half of SURVEY.
Result
Convenience alias used throughout the framework.
Subscriber
The subscribing half of Pub/Sub.
Surveyor
The asking half of SURVEY.