Elffuss BraidHub

utopia-ia/elffuss-braid public

main · 2.2 KiBRawPermalink
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 UtopiaIA
3
4//! The BraidHub protocol, version 1: what the hub and the client (`braid
5//! login`, `braid hub …`, and landing in a linked repository) say to each
6//! other. `docs/hub.md` is the prose of the same contract.
7//!
8//! - [`names`]: owners, repository names and ref globs.
9//! - [`token`]: the `brd_<id>_<secret>` token format.
10//! - [`scope`]: what a token's scopes reach and allow.
11//! - [`stream`]: the `application/x-braid-objects` object stream.
12//! - [`api`]: the JSON bodies of the routes of sections 1 to 14.
13//! - [`cards`]: repositories and accounts as lists hold them.
14//! - [`browse`], [`history`], [`explore`], [`social`], [`issues`],
15//! [`requests`], [`forks`], [`notifications`], [`moderation`] and
16//! [`onboard`]: the bodies of sections 15 to 23.
17//! - [`verify`]: keeping a default branch green, section 25.
18//! - [`json`]: conflicts and changes as the CLI prints them, so a landing on
19//! the hub reports exactly what a local landing does.
20//! - [`limits`]: what one request may carry or ask for.
21
22#![forbid(unsafe_code)]
23
24pub mod api;
25pub mod browse;
26pub mod cards;
27pub mod explore;
28pub mod forks;
29pub mod history;
30pub mod issues;
31pub mod json;
32pub mod limits;
33pub mod moderation;
34pub mod names;
35pub mod notifications;
36pub mod onboard;
37pub mod requests;
38pub mod scope;
39pub mod social;
40pub mod stream;
41pub mod token;
42pub mod verify;
43
44mod hex;
45
46pub use names::{NameError, RepoPath};
47pub use scope::{ParsedScope, Right, ScopeError, ScopeRepo};
48pub use token::{Token, TokenError};
49
50/// The protocol version this crate speaks: the `v1` of every route.
51pub const VERSION: u32 = 1;
52
53/// The media type of an object stream.
54pub const OBJECTS_MEDIA_TYPE: &str = "application/x-braid-objects";
55
56/// The header naming an object's kind on `GET` and `PUT` of `o/{id}`.
57pub const KIND_HEADER: &str = "Braid-Kind";
58
59/// The header naming a git object's kind on `GET git/o/{sha1}`.
60pub const GIT_KIND_HEADER: &str = "Git-Kind";
61
62/// The media type of the ref watch.
63pub const EVENTS_MEDIA_TYPE: &str = "text/event-stream";
64
65/// The public hub, used when nothing else is configured.
66pub const DEFAULT_HUB_URL: &str = "https://braidhub.elffuss.com";