//! The wire shapes of Cotton Vault's screens. Published early so the phone //! lanes draw against them (a `shapes.md` kept beside the work says the same //! in prose, with example answers). Add-only: a field once shipped keeps its //! name and meaning; a new one is optional. //! //! ```text //! vault.items {filter?, q?, after?} → ItemsAnswer //! vault.item {id} → ItemAnswer //! vault.field {id, field, privateKey?} → FieldAnswer (presence) //! vault.code {id, privateKey?} → CodeAnswer //! vault.history {id, privateKey?} → HistoryAnswer (presence) //! vault.edit {id?, kind?, privateKey?} → EditAnswer //! vault.save {id?, kind, name?, site?, username?, fields, favourite?, privateKey?} → ActAnswer //! vault.generate {mode?, length?, words?, lower?, upper?, digits?, symbols?, //! separator?, capitalize?, number?} → GenerateAnswer //! vault.security {platform, privateKey?} → SecurityAnswer //! vault.breach {ranges?, privateKey?} → ActAnswer (two steps) //! vault.settings {platform} → SettingsAnswer //! vault.act {act, id?, value?} → ActAnswer //! vault.look {} → Look (`look.rs`) //! ``` //! //! **The core decides; a phone draws.** Every word below is the kit's //! (`vault` line set), every act names the method and request a tap sends, //! and no answer carries a secret value except `vault.field`, `vault.code` //! and `vault.history`, each to its one caller after presence. use serde::{Deserialize, Serialize}; use serde_json::Value; /// Rows one `vault.items` page holds after its first sections. pub const ITEMS_PAGE: usize = 200; /// Rows "Recently used" holds. pub const RECENT_ROWS: usize = 5; /// Tints an initials picture is drawn on (`tint.` in the look). pub const TINTS: u32 = 8; /// Seconds a copied secret stays on the clipboard unless Settings says otherwise. /// Thirty seconds since Cotton Secrets (owner, 25 Nov 2026; DECISIONS.md question 15). pub const CLIPBOARD_SECONDS: u32 = 30; // ── shared pieces ────────────────────────────────────────────────────── /// A state colour role from the look: `safe` green, `attention` amber, /// `danger` red, `neutral` grey. Never a literal colour. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)] #[serde(rename_all = "lowercase")] pub enum Tone { #[default] Neutral, Safe, Attention, Danger, /// The one accent: the main action only. Accent, } /// A row's picture: typed initials on tint `tint` (0..TINTS). No icon is ever /// fetched for a site: asking a service for one would tell it what you keep. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Picture { pub initials: String, pub tint: u32, /// A symbol name for a kind with no site (`note`, `card`, `wifi`, …); a phone maps it to its own glyph. #[serde(default, skip_serializing_if = "Option::is_none")] pub symbol: Option, } /// What a tap sends: `method` with `request`, after presence when `presence` /// is true, after `confirm` when there is one. `receipt` is said on success. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Act { pub id: String, pub label: String, pub method: String, pub request: Value, #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub presence: bool, #[serde(default, skip_serializing_if = "Option::is_none")] pub confirm: Option, #[serde(default)] pub tone: Tone, /// A symbol name a phone maps to its own glyph (`copy`, `eye`, `star`, `bin`, …). #[serde(default, skip_serializing_if = "Option::is_none")] pub symbol: Option, /// Ask this first, in a sheet: what is typed goes into `request` under `input.key`. #[serde(default, skip_serializing_if = "Option::is_none")] pub input: Option, } /// One field an act asks for before it is sent (a trusted person's number). #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Prompt { pub key: String, pub label: String, pub input: Input, #[serde(default, skip_serializing_if = "Option::is_none")] pub placeholder: Option, /// For `input: choice`, the values offered, in order (Health's sex). Empty for every other input. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub choices: Vec, } /// The question before a destructive act. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Confirm { pub title: String, pub body: String, pub yes: String, pub no: String, } /// A short line a phone shows after an act, and the act that undoes it. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Toast { pub text: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub undo: Option, } /// A health mark on a row or an item: `weak`, `reused`, `old`, `breached`. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Mark { pub id: String, pub label: String, pub tone: Tone, } // ── vault.items ──────────────────────────────────────────────────────── /// One filter chip: `all`, `favourites`, or a kind (`login`, `passkey`, /// `code`, `card`, `note`, `identity`, `wifi`, `address`, `api_key`, /// `document`), and `bin`. Only chips with something behind them are listed. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Chip { pub id: String, pub label: String, pub count: u32, pub on: bool, } /// One saved thing in the list. `id` is a `secret` row's id, or a passkey /// row's id when `kind` is `passkey` (a passkey with no login of its own). #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ItemRow { pub id: String, pub kind: String, /// Its Secrets group: `passwords`, `passkeys`, `cards`, `notes`, `developer`. pub group: String, /// The subtitle is a token or a file line: drawn in the mono face, never wrapped mid-token. #[serde(default)] pub mono: bool, pub title: String, /// The user name, else the site, else the kind's word. pub subtitle: String, pub picture: Picture, pub favourite: bool, /// Weak, reused, old: only when the vault is open on this device (else `old` alone, from the plain date). pub marks: Vec, /// The kit's small trailing word: "Passkey" for a login that also has one. #[serde(default, skip_serializing_if = "Option::is_none")] pub badge: Option, /// Swipe or long-press acts: copy user name, copy password, favourite. pub quick: Vec, } /// One titled run of rows: `favourites`, `recent`, `all` (A–Z), `results`, `bin`. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Section { pub id: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub title: Option, pub rows: Vec, } /// The empty screen's words and its one act. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Empty { pub title: String, pub body: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub act: Option, } /// `vault.items`: the Items screen. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ItemsAnswer { pub title: String, pub search_placeholder: String, pub q: String, pub filter: String, pub chips: Vec, pub sections: Vec
, /// The cursor the next page is asked with (`after`); absent on the last page. #[serde(default, skip_serializing_if = "Option::is_none")] pub next: Option, /// Everything this filter and search hold, across pages. pub total: u32, #[serde(default, skip_serializing_if = "Option::is_none")] pub empty: Option, /// "Recently deleted · 3": opens `filter: bin`. Absent when the bin is empty. #[serde(default, skip_serializing_if = "Option::is_none")] pub bin: Option, /// The prominent add: opens the kind picker. pub add: AddMenu, /// Whether this device holds the vault open now (marks and reveals need it). pub open: bool, } /// The add button and the kinds it offers, most used first. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct AddMenu { pub label: String, pub kinds: Vec, } // ── vault.item ───────────────────────────────────────────────────────── /// One field on an item screen. A concealed field carries no value: its /// `reveal` and `copy` acts ask `vault.field` after presence. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Field { pub key: String, pub label: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub value: Option, pub concealed: bool, /// Drawn in the mono face (passwords, codes, numbers). pub mono: bool, /// A one-time code field: draw `vault.code`'s dial, refreshed by `secondsLeft`. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub live_code: bool, pub acts: Vec, } /// A titled block of fields or facts on the item screen. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Block { pub id: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub title: Option, pub fields: Vec, } /// `vault.item`: one saved thing. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ItemAnswer { pub id: String, pub kind: String, pub kind_label: String, pub title: String, pub subtitle: String, pub picture: Picture, pub favourite: bool, /// The health banner: what is wrong and the act that mends it. #[serde(default, skip_serializing_if = "Option::is_none")] pub banner: Option, /// `fields` (the kind's own), `fills` (where it fills), `history`, `facts` (dates and uses). pub blocks: Vec, /// Edit, favourite, move to bin (or restore, in the bin). pub acts: Vec, /// The vault is shut on this device: optional sealed fields are unknown until `unlock` runs. pub open: bool, #[serde(default, skip_serializing_if = "Option::is_none")] pub unlock: Option, pub in_bin: bool, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Banner { pub text: String, pub tone: Tone, #[serde(default, skip_serializing_if = "Option::is_none")] pub act: Option, } // ── vault.field / vault.code / vault.history ─────────────────────────── /// `vault.field`: one concealed value, to its one caller. `clearAfter` is the /// seconds a phone keeps it on the clipboard, and `toast` what it says. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct FieldAnswer { pub id: String, pub field: String, pub value: String, pub mono: bool, pub clear_after: u32, pub copied_toast: String, } /// `vault.code`: the one-time code now and how long it lasts. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct CodeAnswer { pub id: String, pub code: String, /// The code as drawn: "123 456". pub shown: String, pub seconds_left: u64, pub period: u64, pub clear_after: u32, pub copied_toast: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct PastRow { pub value: String, /// "Used until 3 Nov 2026". pub until: String, pub acts: Vec, } /// `vault.history`: a login's earlier passwords, newest first. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct HistoryAnswer { pub id: String, pub title: String, pub rows: Vec, #[serde(default, skip_serializing_if = "Option::is_none")] pub empty: Option, /// Seconds a copied earlier password stays on the clipboard (Settings' /// choice; 0 keeps it), as every copy answer carries them. #[serde(default)] pub clear_after: u32, } // ── vault.edit / vault.save ──────────────────────────────────────────── /// How a form field takes text. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum Input { Text, Secret, Multiline, Url, Email, Phone, Number, Month, Date, Code, Choice, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Choice { pub value: String, pub label: String, } /// One field of the add or edit form. `key` is `name`, `site`, `username` /// (the plain columns) or the kind's payload field; `vault.save` takes them back /// as `name`/`site`/`username` and `fields.`. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct FormField { pub key: String, pub label: String, pub input: Input, pub required: bool, #[serde(default, skip_serializing_if = "Option::is_none")] pub value: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub placeholder: Option, /// The generator one tap away: `vault.generate` with no request, its `use` act fills this field. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub generate: bool, /// Whether the value is a payload field (`fields.`) rather than a plain column. pub sealed: bool, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub choices: Vec, } /// `vault.edit`: the short form for one kind, new or existing. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct EditAnswer { #[serde(default, skip_serializing_if = "Option::is_none")] pub id: Option, pub kind: String, pub title: String, pub fields: Vec, /// `vault.save`, its request carrying `id` and `kind`; the phone adds what was typed. pub save: Act, pub cancel: String, } /// `vault.save` and `vault.act`: what happened, and what to draw next. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ActAnswer { pub act: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub id: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub toast: Option, /// The item as it now reads, when the act changed one that still stands. #[serde(default, skip_serializing_if = "Option::is_none")] pub item: Option>, /// The item has left the list (moved to the bin): go back. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub gone: bool, /// What only the phone can do next: `{action: "open_url", url}`, /// `{action: "open_fill_settings"}`, `{action: "pick_csv", from, then}` /// (the file picked is sent as `then {csv}`). #[serde(default, skip_serializing_if = "Option::is_none")] pub platform: Option, } // ── vault.generate ───────────────────────────────────────────────────── /// One generator control: a stepper/slider (`min`..`max`), a switch, or a choice. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Control { pub key: String, pub label: String, /// `range`, `switch`, `choice`. pub control: String, pub value: Value, #[serde(default, skip_serializing_if = "Option::is_none")] pub min: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub max: Option, #[serde(default, skip_serializing_if = "Vec::is_empty")] pub choices: Vec, } /// The strength line under a password. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct StrengthLine { /// 0 very weak … 4 strong; a bar of five draws it. pub score: u8, pub label: String, pub tone: Tone, /// "About 112 bits". pub detail: String, } /// `vault.generate`: a fresh password, the controls that made it, and its acts. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct GenerateAnswer { pub title: String, /// `chars`, `words` or `pin`. pub mode: String, pub modes: Vec, pub value: String, pub strength: StrengthLine, pub controls: Vec, /// The request that made this one: send it again for another. pub request: Value, pub again: String, pub copy: Act, /// "Use in a new login": `vault.edit {kind: login}`; a form's generate fills its own field instead. pub use_new: Act, pub use_here: String, pub clear_after: u32, pub copied_toast: String, } // ── vault.security ───────────────────────────────────────────────────── /// One row under Security: a device, a waiting request, an open window, a read, a finding. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Row { pub id: String, pub title: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub detail: Option, #[serde(default)] pub tone: Tone, #[serde(default, skip_serializing_if = "Option::is_none")] pub picture: Option, /// The row's tap: an item, a sheet, a card. #[serde(default, skip_serializing_if = "Option::is_none")] pub open: Option, pub acts: Vec, } /// One titled group on Security or Settings. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Group { pub id: String, pub title: String, #[serde(default, skip_serializing_if = "Option::is_none")] pub detail: Option, pub rows: Vec, #[serde(default, skip_serializing_if = "Option::is_none")] pub empty: Option, /// A group's own act ("Check for breaches", "Make a recovery code"). #[serde(default, skip_serializing_if = "Vec::is_empty")] pub acts: Vec, } /// The password-health summary at the top of Security. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Health { pub title: String, /// "All good" / "3 to look at" / "Open your vault to check". pub summary: String, pub tone: Tone, pub weak: u32, pub reused: u32, pub old: u32, /// Found in a known breach at the last check (`vault.breach`), and not changed since. #[serde(default)] pub breached: u32, /// One count chip per kind of finding; opens the matching group below. pub counts: Vec, pub open: bool, #[serde(default, skip_serializing_if = "Option::is_none")] pub unlock: Option, } /// `vault.security`: health, and what today's Account and unlock cards carry. /// Groups, in order: `waiting`, `windows`, `weak`, `reused`, `old`, `devices`, /// `reads`, `recovery`, `passkeys`. A group with nothing in it keeps its `empty` line. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SecurityAnswer { pub title: String, pub health: Health, pub groups: Vec, } // ── vault.settings ───────────────────────────────────────────────────── /// `vault.settings`: account, lock, clipboard, filling, appearance, import, export, about. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct SettingsAnswer { pub title: String, pub groups: Vec, }