Elffuss BraidHub

utopia-ia/elffuss-braid public

2da7deeea818 · 2.1 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//! - [`json`]: conflicts and changes as the CLI prints them, so a landing on
18//! the hub reports exactly what a local landing does.
19//! - [`limits`]: what one request may carry or ask for.
20
21#![forbid(unsafe_code)]
22
23pub mod api;
24pub mod browse;
25pub mod cards;
26pub mod explore;
27pub mod forks;
28pub mod history;
29pub mod issues;
30pub mod json;
31pub mod limits;
32pub mod moderation;
33pub mod names;
34pub mod notifications;
35pub mod onboard;
36pub mod requests;
37pub mod scope;
38pub mod social;
39pub mod stream;
40pub mod token;
41
42mod hex;
43
44pub use names::{NameError, RepoPath};
45pub use scope::{ParsedScope, Right, ScopeError, ScopeRepo};
46pub use token::{Token, TokenError};
47
48/// The protocol version this crate speaks: the `v1` of every route.
49pub const VERSION: u32 = 1;
50
51/// The media type of an object stream.
52pub const OBJECTS_MEDIA_TYPE: &str = "application/x-braid-objects";
53
54/// The header naming an object's kind on `GET` and `PUT` of `o/{id}`.
55pub const KIND_HEADER: &str = "Braid-Kind";
56
57/// The header naming a git object's kind on `GET git/o/{sha1}`.
58pub const GIT_KIND_HEADER: &str = "Git-Kind";
59
60/// The media type of the ref watch.
61pub const EVENTS_MEDIA_TYPE: &str = "text/event-stream";
62
63/// The public hub, used when nothing else is configured.
64pub const DEFAULT_HUB_URL: &str = "https://braidhub.elffuss.com";