g1t/crates/contracts/src/lib.rs

29 lines881 bytesCodeBlame
1//! Types and service interfaces shared by every g1t service.
2//!
3//! Each service has a module here holding the data it exchanges and the
4//! arguments of each of its methods. Services and their callers depend on
5//! this crate, never on each other's code.
6
7pub mod identity;
8mod ids;
9mod names;
10mod outcome;
11
12pub use ids::new_id;
13pub use names::{is_valid_namespace, is_valid_repo_name};
14pub use outcome::{Failure, FailureCode, Outcome};
15
16use serde::{Deserialize, Serialize};
17
18#[derive(Clone, Debug, Serialize, Deserialize)]
19pub struct User {
20 pub id: String,
21 pub username: String,
22 /// Whether the account's email address has been confirmed. Unverified
23 /// accounts can sign in but cannot create or change anything.
24 #[serde(default)]
25 pub verified: bool,
26}
27
28/// Who is asking. Every read and write in every service takes one.
29pub type Viewer = Option<User>;