Skip to main content

Crate weirdnet_service

Crate weirdnet_service 

Source
Expand description

Weirdnet service framework: one server, many apps.

A server exposes typed request/response Services and live Hub feeds. Apps (desktop, terminal, mobile through a Rust bridge, MCP) connect over Weirdnet streams, present their Credentials once per stream, and every request and subscription is checked by an Authorize hook before it runs.

  • service: request/response sessions. A session is one stream: a Hello with the caller’s credentials, then any number of concurrent calls, each with an id, each authorized on its own Access (permission and resource), cancellable.
  • feed: live topic streams. A Hub keeps each topic’s state and a sequence number; a subscriber gets a snapshot then deltas, resumes from a Position after a reconnect (or gets a fresh snapshot when the gap is too old), and a slow subscriber is coalesced or re-snapshotted instead of stalling the publisher.
  • auth: the Authorize hook, Caller, Access, Admitted and combinators. The roster feature adds RosterAuth (the user’s linked devices and their device-role grants); the access feature adds MembershipAuth (owner-signed memberships and weirdnet-access roles).
  • ProtocolId: versioned protocol ids such as /myapp/api/2.
  • The net feature (default) serves all of this on a weirdnet-net node (Server) and dials it (NetDialer, Client).

Everything below the net feature is transport-neutral: a Channel is any ordered, reliable message channel, and memory_pair gives two connected ends for tests.

Messages are CBOR. The protocol notes describe the wire format, and the design notes explain the choices.

Re-exports§

pub use auth::Access;
pub use auth::Admitted;
pub use auth::AllOf;
pub use auth::AllowAll;
pub use auth::AnyOf;
pub use auth::Authorize;
pub use auth::Caller;
pub use auth::Credentials;
pub use channel::Channel;
pub use channel::Dialer;
pub use channel::FrameRx;
pub use channel::FrameTx;
pub use channel::memory_pair;
pub use error::ServiceError;
pub use feed::Change;
pub use feed::Event;
pub use feed::FeedOptions;
pub use feed::Hub;
pub use feed::HubOptions;
pub use feed::Live;
pub use feed::Overflow;
pub use feed::Position;
pub use feed::State;
pub use feed::Subscription;
pub use feed::Topic;
pub use feed::Watcher;
pub use feed::serve_feed;
pub use protocol::ProtocolId;
pub use protocol::WIRE;
pub use service::Service;
pub use service::Session;
pub use service::SessionOptions;
pub use service::serve_session;

Modules§

access
The access feature: many people on one server, through owner-signed memberships and weirdnet-access roles.
auth
Who is calling, what they ask for, and the hook that decides.
channel
Message channels: the transport-neutral pipe sessions and feeds run over.
codec
CBOR bodies and length-prefixed framing for byte streams (a big-endian u32 length, then the message).
error
Errors, as they travel on the wire.
feed
Live topic feeds: snapshot, then deltas, with resume and backpressure.
net
The net feature: serving and dialing over weirdnet-net streams.
protocol
Versioned protocol ids.
roster
The roster feature: admit the user’s own linked devices (weirdnet-sync roster).
service
Request/response services and sessions.

Structs§

Client
Opens sessions and subscriptions to servers through a Dialer, presenting the same Credentials on each. Cheap to clone.