Expand description
§Flowersec for Rust
The flowersec crate is the Tokio-native SDK for end-to-end encrypted
sessions, RPC, notifications, and reliable byte streams. It supports Rust 1.88
or newer on Linux, macOS, and Windows and contains no Flowersec-authored
unsafe.
§Install
cargo add flowersec§Public API
Parse an invitation with Artifact::parse, bind its durable single-use spend
callback with ArtifactLease, and establish a Session through connect(...).
The public application surface includes Session, RpcPeer, ByteStream,
IncomingStream, StreamMetadata, StreamHandlers, negotiated
UnreliableMessageChannel, and typed RPC through RpcPeerExt::call_typed(...).
let options = flowersec::ConnectorOptions::new()
.with_trust_roots_der(roots)?;
let session = flowersec::connect(lease, options).await?;
session.probe_liveness().await?;
session.close().await?;ConnectionController owns long-lived reconnection. Each attempt acquires a
fresh lease and creates a new Session; it never migrates or replays work from a
terminated Session.
StreamHandlers serves bounded application stream handlers on any established
Session. RpcHandlers configures client RPC and notification callbacks.
SessionHandlers configures accepted server Sessions and composes the same
stream dispatcher.
§Server APIs
Rust exposes the direct Acceptor, opaque TunnelRuntime, and carrier-neutral
ProxyServer. The proxy implements the bounded HTTP and WebSocket application
wire shared with the TypeScript browser runtime.
Reliable stream shutdown is explicit: close_write() sends a graceful FIN and
keeps reads available, while reset() and close() abort both directions.
Handler failures reset only their stream.
§Supported Connections
Rust supports direct and relayed WebSocket and raw QUIC client connections, direct server acceptance, and opaque relay listeners. It does not provide an artifact issuer or WebTransport adapter. Deployments issue artifacts through an application control plane such as the Go control-plane package.
CA candidates use platform or explicit DER trust roots. Pin candidates use only the active artifact-bound leaf-certificate SHA-256 pins and never fall back to CA verification. No system trust store is selected implicitly outside the explicit CA policy. Public errors are closed and redacted; credentials, candidate selection, and protocol state remain private.
See the Rust cookbook, API contract, Transport v3 architecture, wire contract, and error model. Native Rust support for Flowersec secure direct and tunneled sessions over Transport v3.
Maintained callers use the opaque Artifact, one-shot connect,
optional long-lived ConnectionController, and carrier-neutral
Session, direct Acceptor, and opaque TunnelRuntime contracts.
Carrier configuration, candidates, wire formats, and cryptographic state
are crate-private.
use flowersec::framing;use flowersec::client;use flowersec::endpoint;use flowersec::proxy;use flowersec::origin;use flowersec::rpc;use flowersec::stream;use flowersec::protocolio;use flowersec::gen::flowersec::v1;Carrier and wire implementation modules are intentionally inaccessible.
Structs§
- Accept
Error - A redacted direct-acceptance failure without artifact or peer diagnostics.
- Accepted
Session - One accepted public session paired with its frozen handlers.
- Acceptor
- Accepts strict v3 direct sessions without exposing carrier or wire state.
- Acceptor
Options - Runtime-owned raw QUIC bind, TLS identity, and resource policy.
- Artifact
- Artifact
Lease - Artifact
Source Error - Connect
Error - A redacted v3 connection failure with a closed five-code public surface.
- Connection
Controller - Connection
Controller Configuration Error - Invalid public connection-controller configuration.
- Connection
Controller Error - Connection
Controller Options - Connection
Diagnostic - Connection
Diagnostic Failure - Connection
Snapshot - Connector
Options - Native v3 connector trust, handler, and lifecycle configuration.
- Incoming
Stream - One accepted logical stream and its authenticated setup metadata.
- Notification
Subscription - A cancelable subscription for peer-originated RPC notifications.
- Proxy
Server - Application-session proxy protocol owner. It has no carrier or tunnel API.
- Proxy
Server Options - Bounded server-side browser proxy configuration.
- RpcError
- A bounded application failure returned by a remote RPC handler.
- RpcHandlers
- Reusable inbound RPC and notification definitions for client sessions.
- Runtime
Authorization Request - Opaque deployment authorization request for one observed FSB3 tunnel leg.
- Session
Handler Options - Bounded dispatch options for one accepted session.
- Session
Handlers - Immutable handler set consumed by
crate::Acceptor::accept_with_handlers. - Session
Termination - Stable, redacted reason for authoritative session termination.
- Stream
Handler Options - Bounded dispatch options for application streams on any established session.
- Stream
Handlers - Carrier-neutral application-stream registry and dispatcher.
- Stream
Metadata - A validated immutable value accepted as application stream metadata.
- Tunnel
Admission Options - Bounds work performed before an authorized leg enters pairing.
- Tunnel
Authorization Error - Redacted failure returned by an application-owned authorization callback.
- Tunnel
Authorization Response - Opaque, secret-free deployment response for one tunnel leg.
- Tunnel
Runtime - Production strict-v3 opaque tunnel relay.
- Tunnel
Runtime Options - Resource, bind, TLS identity, and origin policy for one opaque relay.
- WebSocket
Acceptor Options - Runtime-owned WSS bind, TLS identity, origin, and resource policy.
Enums§
- Accept
Error Code - Stable, redacted direct-acceptance failure category.
- Artifact
Error - Artifact
Spend Error - Connect
Error Code - Stable, redacted Flowersec v3 connection failure code.
- Connection
Controller Error Code - Connection
Failure - Connection
Failure Phase - Connection
State - Handler
Registration Error - Stable registration failure for invalid or duplicate handlers.
- Proxy
Server Error - Stable server-side proxy failure without upstream or peer details.
- Retry
Disposition - RpcCall
Error - Separates a remote application outcome from a session operation failure.
- Session
Error - Closed, redacted failure set shared by public session, stream, and RPC operations.
- Stream
Metadata Error - Tunnel
Runtime Error - Stable relay lifecycle failure categories.
- Unreliable
Message Error - Stable, redacted failure set for carrier-neutral unreliable messages.
- Unreliable
Message Error Code - Portable code set for unreliable-message failures. Dropped sends remain observable outcomes rather than failures.
- Unreliable
Send Outcome - Observable result of submitting one message to the native unreliable carrier. It does not imply delivery or ordering.
Traits§
- Artifact
Source - Byte
Stream - A reliable encrypted logical byte stream independent of the active carrier.
- Notification
Handler - Handles one inbound RPC notification without producing a response.
- RpcHandler
- Handles one bounded JSON RPC request or notification.
- RpcPeer
- Carrier-neutral RPC access owned by a session.
- RpcPeer
Ext - Type-safe JSON convenience methods layered over the object-safe RPC core.
- Session
- Public Flowersec session contract shared by WSS and raw QUIC.
- Stream
Handler - Handles one authenticated application stream without carrier access.
- Stream
Handler Registrar - Sealed application-stream registration boundary for SDK-owned servers.
- Tunnel
Authorizer - Application-owned authorization boundary for strict v3 tunnel legs.
- Unreliable
Message Channel - Opaque, carrier-neutral unreliable message access owned by a session.
Functions§
- connect
- Establishes one strict v3 session from a single-use artifact lease.
- connect_
with_ cancellation - Establishes one strict v3 session with caller-owned cancellation.
Type Aliases§
- Json
Object - Canonical JSON metadata attached to a logical stream.
- Proxy
Error Reporter