Skip to main content

Crate confium_net

Crate confium_net 

Source
Expand description

Confium Network: transport abstraction for multi-party protocols.

Threshold-cryptography sessions need reliable, ordered byte streams between parties. Confium supplies the transport so plugin authors don’t roll their own socket code. Plugins request a transport by URL ("inproc://session-42", "tcp://1.2.3.4:443", …); Confium dispatches to the registered TransportKind that owns the scheme.

§Built-in transports

This crate ships two built-in transports:

  • transports::inproc — in-process channels for tests and single-process TC simulation.
  • transports::mock — deterministic mock transport with drop/tamper fault injection for Byzantine-peer simulation.

Production transports (tcp, tcp+tls, quic, ws, wss) live in separate crates (confium-net-tcp, etc.) and register via the same register_transport! macro.

§Example

use confium_net as net;

// Listener must be set up before connect consumes it.
let mut listener = net::listen("inproc://demo").unwrap();
let mut client = net::connect("inproc://demo").unwrap();
let mut server = listener.accept().unwrap();

client.send(b"round-1").unwrap();
let mut buf = [0u8; 16];
let n = server.recv(&mut buf).unwrap();
assert_eq!(&buf[..n], b"round-1");

See TODO.roadmap/05-networking-primitives.md for the design.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use registry::TransportKind;
pub use transports::inproc;
pub use transports::mock;
pub use url::TransportUrl;

Modules§

deadline
Deadline-bounded reads and writes over a TcpStream, implemented with non-blocking polling instead of SO_RCVTIMEO.
error
Errors for the Network crate.
io
Adapter from message-framed Transports to byte-stream Read/Write callers.
registry
Open/closed transport-kind registry.
transports
Built-in transports.
url
Transport URL parsing.

Macros§

register_transport
Submit a transport kind to the link-time registry.

Traits§

Listener
A listening endpoint that produces accepted Transports.
Transport
A connected, reliable, ordered, bidirectional byte transport.

Functions§

connect
Connect to the peer identified by url_str.
listen
Begin listening for inbound connections at the address in url_str.