Skip to main content

Crate iroh_http_core

Crate iroh_http_core 

Source
Expand description

iroh-http-core — Iroh QUIC endpoint, HTTP/1.1 via hyper, fetch and serve.

This crate owns the Iroh endpoint and wires HTTP/1.1 framing to QUIC streams via hyper. Nothing in here knows about JavaScript.

Per epic #182 the crate is split into two top-level modules with a one-way dependency:

  • [http] — pure-Rust HTTP-over-iroh primitives. No u64 handles, no callbacks. A pure-Rust application can call http::client::fetch_request and http::server::serve without touching any FFI type.
  • [ffi] — FFI bridge: handle store, callback-shaped serve, flat fetch. Wraps [http]; never imported in the reverse direction (enforced by tests/architecture.rs).

Re-exports§

pub use endpoint::parse_direct_addrs;
pub use endpoint::ConnectionEvent;
pub use endpoint::DiscoveryOptions;
pub use endpoint::EndpointStats;
pub use endpoint::IrohEndpoint;
pub use endpoint::NetworkingOptions;
pub use endpoint::NodeAddrInfo;
pub use endpoint::NodeOptions;
pub use endpoint::PathInfo;
pub use endpoint::PeerStats;
pub use endpoint::PoolOptions;
pub use endpoint::StreamingOptions;
pub use events::TransportEvent;
pub use registry::get_endpoint;
pub use registry::insert_endpoint;
pub use registry::remove_endpoint;

Modules§

endpoint
Iroh endpoint lifecycle — create, share, and close.
events
registry

Structs§

Body
Single HTTP body type used everywhere in iroh-http-core.
BodyReader
Consumer end — stored in the reader registry. Uses tokio::sync::Mutex so we can .await the receiver without holding the registry’s std::sync::Mutex.
CloseInfo
Close information returned when a session ends.
CompressionOptions
Compression options for response bodies (server) and outgoing requests (client; reserved).
CoreError
Structured error returned by core functions.
FfiDuplexStream
Handles for the two sides of a full-duplex QUIC stream.
FfiResponse
Flat response-head struct that crosses the FFI boundary.
HandleStore
Per-endpoint handle registry. Owns all body readers, writers, sessions, request-head rendezvous channels, and fetch-cancel tokens for a single IrohEndpoint.
ParsedNodeAddr
Parsed node address from a ticket string, bare node ID, or JSON address info.
RemoteNodeId
Authenticated peer node id of the QUIC connection a request arrived on. Inserted as a request extension by the per-connection tower_http::add_extension::AddExtensionLayer in serve_with_events.
RequestPayload
Options passed to the JS serve callback per incoming request.
ResponseHeadEntry
ServeHandle
ServeOptions
Options for the HTTP serve loop.
Session
A QUIC session to a single remote peer.
StackConfig
Tower stack configuration shared by [build_stack] and [build_client_stack].
StoreConfig
Configuration for a HandleStore. Set once at endpoint bind time.

Enums§

ErrorCode
Machine-readable error codes for the FFI boundary.
FetchError
Typed error returned by the pure-Rust fetch_request API.

Constants§

ALPN
ALPN for the HTTP/1.1-over-QUIC protocol (version 2 wire format).
ALPN_DUPLEX
ALPN for base + bidirectional streaming sessions.
ALPN_DUPLEX_STR
String form of ALPN_DUPLEX, for use in NodeOptions::capabilities.
ALPN_STR
String form of ALPN, for use in NodeOptions::capabilities.
KNOWN_ALPNS
All recognised ALPN capability strings.

Functions§

base32_encode
Encode bytes as lowercase RFC 4648 base32 (no padding).
fetch
FFI-shaped fetch — re-exported as iroh_http_core::fetch for FFI binary compatibility (Slice D acceptance #5). Composition mirrors the pre-Slice-D function exactly; the moving parts that became pure Rust live in crate::http::client::fetch_request.
fetch_request
Pure-Rust outbound entry — the canonical client API.
ffi_serve
Back-compat 3-arg FFI serve entry: equivalent to ffi_serve_with_callback with on_connection_event = None. The Node / Deno / Tauri adapters call this directly.
ffi_serve_with_callback
FFI-shaped serve entry. Constructs an [IrohHttpService] around the supplied callback and delegates to the pure-Rust crate::http::server::serve_with_events.
generate_secret_key
Generate a fresh Ed25519 secret key. Returns 32 raw bytes, or Err if the RNG panics.
make_body_channel
Create a matched (writer, reader) pair backed by a bounded mpsc channel.
node_ticket
Generate a ticket string for the given endpoint.
parse_node_addr
Parse a string that may be a bare node ID, a ticket string (JSON-encoded NodeAddrInfo), or a JSON object with id and addrs fields.
public_key_verify
Verify a 64-byte Ed25519 signature against a 32-byte public key. Returns true on success, false on any failure (including panics).
respond
Send the response head for a request handle previously delivered to JS via the RequestPayload::req_handle callback.
secret_key_sign
Sign arbitrary bytes with a 32-byte Ed25519 secret key. Returns a 64-byte signature, or Err if the underlying crypto panics.
serve
Pure-Rust serve entry — convenience 3-arg wrapper that omits the connection-event callback. Equivalent to serve_with_events(ep, opts, svc, None).
serve_with_events
Pure-Rust serve entry — the canonical inbound API.

Type Aliases§

BoxError
Boxed dynamic error used by Body and the serve service contract.