Skip to main content

weirdnet_contacts/
lib.rs

1//! A contact book for Weirdnet apps.
2//!
3//! - [`Book`]: who you know, as [`ContactState::Trusted`], [`ContactState::Blocked`] or not at
4//!   all, a ban list keyed by identity, and your [`PresencePolicy`].
5//! - Presence with privacy rules ([`presence`]): everyone online sees your base state (online,
6//!   away or busy), and only trusted contacts see the detail fields (status line, in-session
7//!   hint, last seen) that your policy allows. [`presence::view_for`] decides, in one place.
8//! - Signed text direct messages and invite cards ([`message`]) with a delivery state, an
9//!   offline queue and conversations that merge, so two nodes (or your own devices) converge
10//!   after they were apart.
11//! - [`ContactLink`]: a `weirdnet-contact:` link or QR payload that adds someone.
12//! - [`Contacts`]: the live state behind one `Mutex`, [`service::ContactsService`] to serve it
13//!   over [`weirdnet_service`], and [`client`] to send, flush, pull and read presence.
14//!
15//! An identity here is the transport peer id ([`UserId`]): the service authorizes a caller by
16//! the peer the connection proved, and a message must come from the peer that signed it. The
17//! crate is app-neutral and keeps nothing on disk: [`Contacts::snapshot`] and
18//! [`Contacts::restore`] give the app plain serde data to store as it likes.
19//!
20//! The relay never carries messages or detail presence; those go node to node. Finding who is
21//! online is the job of `weirdnet-presence`.
22#![forbid(unsafe_code)]
23
24pub mod book;
25pub mod client;
26pub mod contacts;
27pub mod id;
28pub mod link;
29pub mod message;
30pub mod presence;
31pub mod service;
32
33pub use book::{Book, Contact, ContactState};
34pub use contacts::{Contacts, Receipt, Refusal, Snapshot};
35pub use id::{IdError, UserId};
36pub use link::ContactLink;
37pub use message::{Body, Conversation, Delivery, DirectInvite, Entry, Message, MessageId};
38pub use presence::{Audience, Detail, InSession, Presence, PresenceInfo, PresencePolicy, PresenceView, SessionHint, Viewer};