sew_proto/lib.rs
1#![deny(missing_docs)]
2//! Sew wire contracts.
3//!
4//! Every wire type lives here: ids, chat addresses, errors, HTTP request and response bodies,
5//! gateway frames and events, change-log kinds, mgmt API bodies, permission bits, org policies
6//! and audit events. Server, clients and K2 share this crate; nothing else defines wire JSON.
7//!
8//! The crate is pure: it reads the clock (only in [`clock`]) and does no other IO. It builds on
9//! macOS as well as Linux.
10
11#[macro_use]
12mod macros;
13
14pub mod addr;
15pub mod api;
16pub mod audit;
17pub mod calls;
18pub mod changes;
19pub mod clock;
20pub mod e2ee;
21pub mod emoji_token;
22pub mod error;
23pub mod export;
24pub mod external_id;
25pub mod gateway;
26pub mod http;
27pub mod id;
28pub mod install;
29pub mod limits;
30pub mod links;
31pub mod mention;
32pub mod mgmt;
33pub mod pass;
34pub mod perms;
35pub mod policy;
36pub mod recording;
37pub mod registry;
38pub mod routes;
39pub mod search;
40pub mod time;
41pub mod token;
42pub mod voice;
43pub mod voice_notify;
44pub mod when;
45
46mod examples;
47
48/// Client API and gateway protocol version. Changes only with a breaking change after the
49/// first release.
50pub const PROTOCOL_VERSION: u32 = 1;
51
52/// Logical export archive format version carried in export manifests.
53pub const EXPORT_FORMAT: u32 = 1;
54
55/// Additive revision of export format 1. Readers refuse archives with
56/// a higher minor (`format_too_new`); a breaking change bumps [`EXPORT_FORMAT`]. Minor 1:
57/// `spaces.ndjson` records carry the space's default channels, description, rules
58/// and welcome channels. Minor 2: they also carry the App a space belongs to. Minor 3:
59/// and whether a space is hidden. Minor 4: `space_bans.ndjson` and
60/// `space_timeout_carry.ndjson`; importing an older minor gives every role holding
61/// REMOVE_MEMBERS (bit 38) BAN_MEMBERS (bit 47), as the migration did. Minor 5: message
62/// records of on-behalf posts carry `on_behalf_approval`; an older archive's on-behalf posts
63/// import as pending. Minor 6: space records carry `private`; a private space imports
64/// invite-only. Minor 7: space records carry `orphaned_from`, member records
65/// `relinked_from` and the install record `identity_switched_at`. Minor 8 (Sew 0.6.0):
66/// space records carry `governance` and role records the managed-role mark `managed`. Minor 9
67/// (Sew 0.7.0): space records may carry governance `server` (the server-governed Space,
68/// owned by the `k2:server` member) and channel records `closing`. Minor 10 (Sew 0.8.0): space
69/// records carry `participant_app_ids` (the participant links). Minor 11: member records of an
70/// erased account carry `erased_at` and `erase_mode` (with the `erased:<id>` external id),
71/// messages and attachments the delete and remove kind `erased`. Minor 12 (Sew 0.9.0): space
72/// records carry the recording overrides `recording_start_level` and `recording_required`,
73/// voice channel records `recording_required`, and recording records `trigger: required` for a
74/// recording a required room started. Minor 13 (Sew 0.10.0): channel records carry
75/// `members_can_leave`. Minor 14: full exports carry `dm_seen.ndjson` and
76/// `read_receipt_prefs.ndjson` (read receipts in DMs).
77pub const EXPORT_FORMAT_MINOR: u32 = 14;
78
79/// The first export minor that carries BAN_MEMBERS (bit 47) itself.
80pub const EXPORT_MINOR_BAN_MEMBERS: u32 = 4;
81
82/// The recorder participant's user-facing name. Clients label
83/// the recorder's roster entry, the recording banner and notices with it. The engine never sees
84/// it (only the pseudonymous `p_…` identity); the binary, unit and user stay
85/// Sew's call recorder (not published).
86pub const RECORDER_DISPLAY_NAME: &str = "Bobbin";
87
88pub use addr::{Addr, AddrError, ChannelRef, DmTarget, Handle, Slug, SpaceRef};
89pub use clock::{Clock, SystemClock};
90pub use error::{ApiError, Code, ErrorBody, Validate, ValidationError};
91pub use external_id::ExternalId;
92pub use http::{IdempotencyKey, Nonce, Page, PageQuery, Patch};
93pub use id::{Id, IdGenerator, IdList, NodeId, id_to_time};
94pub use perms::Perms;
95pub use time::Timestamp;
96
97/// README.md's examples, compiled and run as doc tests.
98#[cfg(doctest)]
99#[doc = include_str!("../README.md")]
100struct ReadmeExamples;