weirdnet_service/lib.rs
1//! Weirdnet service framework: one server, many apps.
2//!
3//! A server exposes typed request/response [`Service`]s and live [`Hub`] feeds. Apps (desktop,
4//! terminal, mobile through a Rust bridge, MCP) connect over Weirdnet streams, present their
5//! [`Credentials`] once per stream, and every request and subscription is checked by an
6//! [`Authorize`] hook before it runs.
7//!
8//! - [`service`]: request/response sessions. A session is one stream: a `Hello` with the
9//! caller's credentials, then any number of concurrent calls, each with an id, each
10//! authorized on its own [`Access`] (permission and resource), cancellable.
11//! - [`feed`]: live topic streams. A [`Hub`] keeps each topic's state and a sequence number;
12//! a subscriber gets a snapshot then deltas, resumes from a [`Position`] after a reconnect
13//! (or gets a fresh snapshot when the gap is too old), and a slow subscriber is coalesced or
14//! re-snapshotted instead of stalling the publisher.
15//! - [`auth`]: the [`Authorize`] hook, [`Caller`], [`Access`], [`Admitted`] and combinators.
16//! The `roster` feature adds [`RosterAuth`](roster::RosterAuth) (the user's linked devices
17//! and their device-role grants); the `access` feature adds
18//! [`MembershipAuth`](access::MembershipAuth) (owner-signed memberships and
19//! `weirdnet-access` roles).
20//! - [`ProtocolId`]: versioned protocol ids such as `/myapp/api/2`.
21//! - The `net` feature (default) serves all of this on a `weirdnet-net` node
22//! ([`Server`](net::Server)) and dials it ([`NetDialer`](net::NetDialer), [`Client`]).
23//!
24//! Everything below the `net` feature is transport-neutral: a [`Channel`] is any ordered,
25//! reliable message channel, and [`memory_pair`] gives two connected ends for tests.
26//!
27//! Messages are CBOR. The [protocol notes](https://github.com/WeirdBrains/weirdnet-service/blob/main/docs/protocol.md)
28//! describe the wire format, and the [design notes](https://github.com/WeirdBrains/weirdnet-service/blob/main/docs/design.md)
29//! explain the choices.
30
31pub mod auth;
32pub mod channel;
33pub mod codec;
34pub mod error;
35pub mod feed;
36pub mod protocol;
37pub mod service;
38
39#[cfg(feature = "access")]
40pub mod access;
41#[cfg(feature = "net")]
42pub mod net;
43#[cfg(feature = "roster")]
44pub mod roster;
45
46mod client;
47
48pub use auth::{Access, Admitted, AllOf, AllowAll, AnyOf, Authorize, Caller, Credentials};
49pub use channel::{Channel, Dialer, FrameRx, FrameTx, memory_pair};
50pub use client::Client;
51pub use error::ServiceError;
52pub use feed::{Change, Event, FeedOptions, Hub, HubOptions, Live, Overflow, Position, State, Subscription, Topic, Watcher, serve_feed};
53pub use protocol::{ProtocolId, WIRE};
54pub use service::{Service, Session, SessionOptions, serve_session};