//! The wire shapes of Cotton Chat's five methods. Published early so the//! phone lanes build against them (a `shapes.md` kept beside the work//! says the same in prose). Add-only: a field once shipped keeps its name//! and meaning; a new one is optional.//!//! ```text//! chat.list {filter?, search?, after?} → ListAnswer//! chat.thread {thread, before?, after?, around?} → ThreadAnswer//! chat.compose {thread, text?, replyTo?, edit?, cancel?} → ComposeAnswer//! chat.act {act, thread, message?, messages?, text?, emoji?, to?, until?} → ActAnswer//! chat.themes {} → ThemesAnswer//! chat.theme.set {appearance: "light"|"dark", id} → ThemesAnswer//! chat.theme {theme, dark} / chat.text {value} / chat.ground {ground} → ThemesAnswer//! ```use std::collections::BTreeMap;use serde::{Deserialize, Serialize};pubusecrate::messages::ticks::MessageTickasTick;/// Rows a list page holds. The stride is the read's, never the phone's.pubconst LIST_PAGE: usize = 80;/// Messages a thread page holds.pubconst THREAD_PAGE: usize = 60;/// Counts stop here: a badge past it says [`badge`]'s "999+".pubconst COUNT_CEILING: u32 = 1000;/// A count as a badge says it.pubfn badge(count: u32) -> String {if count >= COUNT_CEILING { format!("{}+", COUNT_CEILING - 1) } else { count.to_string() }}/// Bubbles from one sender group while each follows the last within this.pubconst GROUP_GAP_MS: i64 = 5 * 60_000;/// Tints a typed-initials picture is drawn on (`chat.tint.<n>` in a theme).pubconst TINTS: u32 = 8;// ── chat.list ───────────────────────────────────────────────────────────/// Which conversations the list shows: a fan tile's id.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]#[serde(rename_all = "lowercase")]pubenumFilter { #[default]All,People,Groups,Unread,Archived,/// The last word was theirs and is unanswered.Waiting,/// One source: `cotton`, `whatsapp`, `sms`, … #[serde(untagged)]Source(String),}implFilter {pubfn parse(text: Option<&str>) -> Filter {match text.unwrap_or("all") {"all" | "" => Filter::All,"people" => Filter::People,"groups" => Filter::Groups,"unread" => Filter::Unread,"archived" => Filter::Archived,"waiting" => Filter::Waiting, other => Filter::Source(other.to_string()), } }pubfn id(&self) -> &str {matchself {Filter::All => "all",Filter::People => "people",Filter::Groups => "groups",Filter::Unread => "unread",Filter::Archived => "archived",Filter::Waiting => "waiting",Filter::Source(s) => s, } }}/// A round picture: the photo's media key when there is one, else typed/// initials on a tint (`tint` is 0..TINTS, a theme's `chat.tint.<n>`).#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructPicture { #[serde(default, skip_serializing_if = "Option::is_none")]pub photo: Option<String>,pub initials: String,pub tint: u32,}/// The small mark before a last line or inside a bubble.#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "lowercase")]pubenumMark {Photo,Album,Video,Voice,Audio,File,Contact,Location,Poll,Deleted,}/// A conversation's last line.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructLastLine {pub text: String,/// The sender's first name, in a group ("You" for your own). #[serde(default, skip_serializing_if = "Option::is_none")]pub sender: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub mark: Option<Mark>,pub mine: bool,/// Your own last line's tick. #[serde(default, skip_serializing_if = "Option::is_none")]pub tick: Option<Tick>,/// Where your own last line stands while it is on its way to WhatsApp through the Mac, in the bubble's own words/// ("Waiting to send", "Sending…", "Not sent: <why>"); absent once it has gone, and on every other line. #[serde(default, skip_serializing_if = "Option::is_none")]pub state: Option<String>,}/// One swipe action on a row: the act `chat.act` takes, and its word.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructSwipe {pub act: String,pub label: String,/// The question asked before the act runs (Delete); none for an act that runs at once. #[serde(default, skip_serializing_if = "Option::is_none")]pub confirm: Option<String>,}/// One conversation in the list.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructListRow {pub thread: String,pub name: String,pub group: bool,/// Where it is from (`cotton`, `whatsapp`, `sms`, …).pub source: String,pub picture: Picture, #[serde(default, skip_serializing_if = "Option::is_none")]pub last_line: Option<LastLine>,/// The time today, "Yesterday", else the day. #[serde(default, skip_serializing_if = "Option::is_none")]pub when: Option<String>,/// Unread messages; 0 draws no badge. Counted to a ceiling (1000).pub unread: u32,/// What the badge says: the count, "999+" past the ceiling; none at 0. #[serde(default, skip_serializing_if = "Option::is_none")]pub badge: Option<String>,/// Marked unread by hand: a badge with no number.pub marked_unread: bool,pub pinned: bool,pub muted: bool,pub archived: bool,/// The typing line where the source gives it. #[serde(default, skip_serializing_if = "Option::is_none")]pub typing: Option<String>,/// A draft waiting in the composer, said as the last line is. #[serde(default, skip_serializing_if = "Option::is_none")]pub draft: Option<String>,/// A message can be written into it from here (Forward's picker keeps these). #[serde(default)]pub sendable: bool,/// Swipe from the leading edge (read / unread, pin), then the trailing (mute, archive).pub leading: Vec<Swipe>,pub trailing: Vec<Swipe>,/// A long press: Mark as read or Mark as unread, Pin, Mute, Archive, Delete (`list::hold`). #[serde(default)]pub hold: Vec<Swipe>,}/// A fan tile, in the fan's order.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructFanTile {/// A filter id, or `account`.pub id: String,pub label: String,/// Conversations under it (unread ones for Unread); none on Account. #[serde(default, skip_serializing_if = "Option::is_none")]pub count: Option<u32>,pub on: bool,}#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructListCounts {pub all: u32,pub people: u32,pub groups: u32,/// Conversations with anything unread (not archived).pub unread: u32,pub archived: u32,/// Conversations whose last word was theirs (not archived). #[serde(default)]pub waiting: u32,pub sources: BTreeMap<String, u32>,}#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructListWords {pub title: String,pub search: String,/// What stands where no row does (the filter's own line, or none found).pub empty: String,}/// `chat.list`.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructListAnswer {pub filter: String, #[serde(default, skip_serializing_if = "Option::is_none")]pub search: Option<String>,/// Pinned first, then newest.pub rows: Vec<ListRow>,/// Hand back as `after` for the next page; none at the end. #[serde(default, skip_serializing_if = "Option::is_none")]pub next: Option<String>,pub counts: ListCounts,pub fan: Vec<FanTile>,/// The filters above the list, in order: All, Unread, Groups. #[serde(default)]pub filters: Vec<FanTile>,pub words: ListWords,}// ── chat.thread ─────────────────────────────────────────────────────────/// What a bubble is.#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "lowercase")]pubenumBubbleKind {Text,Photo,Album,Video,Voice,Audio,File,Contact,Location,Poll,Deleted,}/// One attachment as a bubble draws it.#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructMediaPart {/// Opened through `chat.picture {message, index}` / the media store.pub index: u32,pub kind: Mark, #[serde(default, skip_serializing_if = "Option::is_none")]pub name: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub width: Option<f64>, #[serde(default, skip_serializing_if = "Option::is_none")]pub height: Option<f64>,/// "0:12" for voice, audio and video. #[serde(default, skip_serializing_if = "Option::is_none")]pub length: Option<String>,/// "2.4 MB" for a file. #[serde(default, skip_serializing_if = "Option::is_none")]pub size: Option<String>,/// Voice, audio and video: the length as a number, which a player's/// countdown and position need (`length` is its words). #[serde(default, skip_serializing_if = "Option::is_none")]pub duration_ms: Option<u64>,/// Voice: samples in 0..1, as the recorder sent them (up to 64). Kept/// for phones that know nothing of `bars`. #[serde(default, skip_serializing_if = "Option::is_none")]pub waveform: Option<Vec<f64>>,/// Voice: exactly [`super::bubble::BARS`] heights in 0..1, worked out/// from `waveform` by [`super::bubble::bars`], so both phones draw the/// same bars from the same note. Absent when there is no waveform (the/// player draws its thin track). #[serde(default, skip_serializing_if = "Option::is_none")]pub bars: Option<Vec<f64>>,/// Voice: false on a voice message of theirs nobody has played on any/// of the person's phones (`chat.act played`). Absent is played: the/// person's own, and an imported note. #[serde(default = "played_default", skip_serializing_if = "is_played")]pub played: bool,/// A tiny base64 JPEG drawn blurred until the bytes are local. #[serde(default, skip_serializing_if = "Option::is_none")]pub preview: Option<String>,/// A shared contact's name and first number. #[serde(default, skip_serializing_if = "Option::is_none")]pub contact: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub number: Option<String>,/// The store said it does not hold the file (it answered 404 when last/// asked, `cotton_client::media::absent`), and it is not asked again/// until its wait is over: drawn as not available, never an empty box. #[serde(default, skip_serializing_if = "std::ops::Not::not")]pub gone: bool,/// A voice message's words, transcribed on the sender's phone and sealed/// like the message, following it: drawn under the player, so nobody has/// to listen. #[serde(default, skip_serializing_if = "Option::is_none")]pub transcript: Option<String>,/// The message this part opens through (`chat.picture {message, index}`), when it is not the bubble's: a grid of/// one tap's pictures to WhatsApp, each its own message (FEEDBACK-4 B3, CONTRACT "Several pictures to WhatsApp,/// one grid"). Absent, the bubble's. #[serde(default, skip_serializing_if = "Option::is_none")]pub message: Option<String>,}fn played_default() -> bool {true}fn is_played(played: &bool) -> bool { *played}/// The link a phone fetches a card for, from the words being written.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]pubstructPreviewAsk {pub url: String,}/// `chat.preview`'s answer: the page the phone fetched, read as its card; `image` the picture the phone fetches and/// makes the card's `thumb`.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructPreviewCard {pub url: String, #[serde(default, skip_serializing_if = "Option::is_none")]pub site: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub title: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub description: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub image: Option<String>,}/// A link unfolded into a card.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructLinkCard {pub url: String, #[serde(default, skip_serializing_if = "Option::is_none")]pub site: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub title: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub description: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub thumb: Option<String>,}/// The quoted line of a reply; a tap goes to `message` (`chat.thread {around}`).#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructQuote { #[serde(default, skip_serializing_if = "Option::is_none")]pub message: Option<String>,pub sender: String,pub line: String, #[serde(default, skip_serializing_if = "Option::is_none")]pub mark: Option<Mark>,}/// Reactions under a bubble, one per emoji, in first-seen order.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructReaction {pub emoji: String,pub count: u32,pub mine: bool,}/// Who wrote a bubble in a group, said on the group's first bubble (name)/// and its last (picture).#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructSender {pub name: String,pub picture: Picture,/// 0..TINTS: the name's ink in a group (`chat.name.<n>`).pub tint: u32,}/// The agent a bubble is from: its name and whose it is ("Asha's agent", "Your agent").#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructAgentTag {pub id: String,pub name: String,pub line: String,}/// One bubble.#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructBubble {pub message: String,pub mine: bool,pub kind: BubbleKind, #[serde(default, skip_serializing_if = "Option::is_none")]pub text: Option<String>,/// In a group, on a bubble from someone else. #[serde(default, skip_serializing_if = "Option::is_none")]pub sender: Option<Sender>,/// Said by an agent (an agent in a chat, 23 Nov 2026): drawn on the left with the agent's mark, its name and/// whose agent it is, even on its person's own phones (`mine` is then false). #[serde(default, skip_serializing_if = "Option::is_none")]pub agent: Option<AgentTag>,/// First of a run from one sender: the gap above it.pub head: bool,/// Last of the run: the tail.pub tail: bool,/// First of one sender's unbroken words in a day: their picture, and in a/// group their name, stand here once (a pause starts a run, not a face). #[serde(default)]pub face: bool,/// The clock.pub time: String, #[serde(default, skip_serializing_if = "Option::is_none")]pub tick: Option<Tick>,/// The person's own message still going (`tick` sending): until this/// moment, ms since the epoch, nothing is drawn under it, so a send that/// goes at once never flashes "Sending" ([`crate::messages::app::bubble::QUIET_SENDING_MS`]/// after it was written); from then "Sending" stands until the tick moves. #[serde(default, skip_serializing_if = "Option::is_none")]pub quiet_until: Option<i64>,/// Where the person's own text stands, in words, drawn under the bubble when present: a WhatsApp text on its/// way through the Mac ("Waiting to send", "Sending…", "Not sent: <why>"). Never "Sent" before it was. #[serde(default, skip_serializing_if = "Option::is_none")]pub state: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub edited: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub forwarded: Option<String>,pub pinned: bool, #[serde(default, skip_serializing_if = "Option::is_none")]pub reply: Option<Quote>, #[serde(default, skip_serializing_if = "Vec::is_empty")]pub reactions: Vec<Reaction>, #[serde(default, skip_serializing_if = "Vec::is_empty")]pub media: Vec<MediaPart>, #[serde(default, skip_serializing_if = "Option::is_none")]pub link: Option<LinkCard>,/// What a long press offers, in order: `chat.act`'s acts plus `copy` and `select`.pub actions: Vec<String>,/// Where a search asked for (`chat.thread { find }`) stands in `text`, in/// UTF-16 `[start, end)`: drawn marked. Empty when nothing was asked. #[serde(default, skip_serializing_if = "Vec::is_empty")]pub marks: Vec<[u32; 2]>,/// Starred by this person (`chat.act star`): private, kept in their own database. #[serde(default, skip_serializing_if = "std::ops::Not::not")]pub starred: bool,/// Where this message went or came by, in a chat holding both Cotton's and WhatsApp's messages on a linked copy/// (FEEDBACK-2 A): "on Cotton" or "via WhatsApp", drawn small by the time. Absent anywhere else. #[serde(default, skip_serializing_if = "Option::is_none")]pub place: Option<PlaceMark>,/// The phone numbers in its words (`numbers::numbers_in`): a tap on one opens that number's chat, as/// `chat.start { number }` routes it (FEEDBACK-2 A). Empty when it holds none. #[serde(default, skip_serializing_if = "Vec::is_empty")]pub numbers: Vec<NumberAt>,/// The links in its words (`links::links_at`: only an explicit `http(s)://`), where each stands and where it goes:/// a tap opens the page inside Comms (a Custom Tab on Android, Safari's sheet on iPhone), never out to the browser./// Empty when it holds none. #[serde(default, skip_serializing_if = "Vec::is_empty")]pub links: Vec<LinkAt>,/// A poll, drawn as one (`poll::card`; CONTRACT "Polls shown"): its words stand here, never as `text`. #[serde(default, skip_serializing_if = "Option::is_none")]pub poll: Option<PollCard>,}/// A poll as the bubble draws it.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructPollCard {pub question: String,/// "Select one" or "Select one or more"; absent on an exported poll. #[serde(default, skip_serializing_if = "Option::is_none")]pub choose: Option<String>,pub options: Vec<PollChoice>,/// Everyone who voted, once each ("5 votes", "No votes yet"); an export's, the sum.pub said: String,/// The whole poll as one line, for TalkBack and VoiceOver.pub spoken: String,/// The Votes sheet's title.pub votes_title: String,/// He can vote here (a WhatsApp poll his Mac's link sends to): a tap on an option is `chat.act vote`. #[serde(default, skip_serializing_if = "std::ops::Not::not")]pub votable: bool,}/// One option of a poll.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructPollChoice {pub text: String,pub votes: u32,/// "3 votes", "1 vote", "No votes".pub said: String,/// Its part of the people who voted, 0 to 100: the bar's length.pub percent: u32,/// Who chose it, as the chat names them: "You" first, then in the order they voted. #[serde(default, skip_serializing_if = "Vec::is_empty")]pub voters: Vec<String>,/// The owner's own choice. #[serde(default, skip_serializing_if = "std::ops::Not::not")]pub mine: bool,}/// A phone number in a message's words: where it stands (UTF-16 `[start, end)`, as `marks`) and as E.164.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructNumberAt {pub at: [u32; 2],pub number: String,}/// A link in a message's words: UTF-16 `[start, end)` and the address it opens.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructLinkAt {pub at: [u32; 2],pub url: String,}/// One item of a thread page, oldest first.#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]#[serde(tag = "item", rename_all = "lowercase")]pubenumItem {Day { label: String,/// The day drawn as a large numeral ("20") … #[serde(default, skip_serializing_if = "Option::is_none")] numeral: Option<String>,/// … and the words beside it ("Friday · November"). #[serde(default, skip_serializing_if = "Option::is_none")] words: Option<String>, },Unread { label: String },/// A group event or an importer's aside, centred.Event { message: String, text: String,/// What a tap on the line opens, where it opens something: `safety`, the/// safety number's screen (CONTRACT.md "Safety number"). #[serde(default, skip_serializing_if = "Option::is_none")] opens: Option<String>, },/// A mail between the person and whoever this chat is with, by time among/// the messages (MAIL.md): marked as mail, opening whole (`chat.mail.thread`).Mail(MailCard),Bubble(Bubble),}/// One mail in a conversation, drawn as a quiet card marked as mail.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructMailCard {/// The email's id.pub email: String,/// Its conversation of mail: what `chat.mail.thread` opens.pub mail_thread: String,/// The person sent it (drawn on the right, as their own words).pub mine: bool,/// "Mail", beside the envelope mark.pub mark: String,pub subject: String,/// Its first words on one line. #[serde(default, skip_serializing_if = "Option::is_none")]pub line: Option<String>,/// "2 attachments". #[serde(default, skip_serializing_if = "Option::is_none")]pub attachments: Option<String>,pub unread: bool,/// Its clock ("09:41").pub time: String,/// When it was sent, RFC 3339.pub at: String,}#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructHeader {pub name: String,pub picture: Picture,pub group: bool,pub source: String,/// Members in a group; typing or last seen where the source gives it. #[serde(default, skip_serializing_if = "Option::is_none")]pub status: Option<String>,/// Where a message written here goes, on a copy linked to WhatsApp through the Mac (FEEDBACK-2 A): drawn/// under the name. Absent unlinked, and where nothing can be written. #[serde(default, skip_serializing_if = "Option::is_none")]pub place: Option<PlaceMark>,/// Acts on his WhatsApp itself for a person's WhatsApp chat (owner, 24 Nov 2026; chat CONTRACT "Blocking a/// WhatsApp sender, deleting a WhatsApp chat"): Block on WhatsApp, and Delete on WhatsApp too. Each is a/// `chat.act`; the delete answers `count_first` with the count before it runs. Absent elsewhere. #[serde(default, skip_serializing_if = "Vec::is_empty")]pub acts: Vec<Swipe>,}/// Where a message goes, said before it is sent: `cotton` ("on Cotton") or `whatsapp` ("via WhatsApp").#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructPlaceMark {pub id: String,pub mark: String,}/// The pinned-message bar: the newest pin, and how many there are.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructPinnedBar {pub message: String,pub title: String,pub line: String,pub count: u32,}/// A stranger's first message waits on an answer: their words stand, and/// Accept, Block and Delete go to `chat.accept` / `chat.block` / `chat.refuse`.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructRequestCard {pub title: String,pub line: String,pub accept: String,pub block: String,pub refuse: String,}/// Jump to latest, with the count of what came in below.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructJump {pub count: u32,pub label: String,/// The count as the button says it ("999+" past the ceiling).pub badge: String,}#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructActionWords {pub reply: String,pub react: String,pub copy: String,pub forward: String,pub edit: String,pub delete: String,/// Delete for me, in a WhatsApp chat that sends: his copy only (chat CONTRACT.md "Delete for me"). #[serde(default)]pub delete_mine: String,pub pin: String,pub unpin: String,pub select: String,/// Message info: who in a group has the person's words (`chat.group.receipts`). #[serde(default)]pub info: String,/// Star and Unstar (`chat.act star` / `unstar`). #[serde(default)]pub star: String, #[serde(default)]pub unstar: String,pub copied: String,/// The few emoji a react row offers first.pub emoji: Vec<String>,}/// `chat.thread`: a page of items oldest first.#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructThreadAnswer {pub thread: String,pub header: Header, #[serde(default, skip_serializing_if = "Option::is_none")]pub pinned: Option<PinnedBar>,pub items: Vec<Item>,/// Hand back as `before` for the page above; none at the top. #[serde(default, skip_serializing_if = "Option::is_none")]pub older: Option<String>,/// Hand back as `after` for the page below; none at the newest. #[serde(default, skip_serializing_if = "Option::is_none")]pub newer: Option<String>,/// The message `around` asked for, to scroll to and flash. #[serde(default, skip_serializing_if = "Option::is_none")]pub focus: Option<String>,pub unread: u32, #[serde(default, skip_serializing_if = "Option::is_none")]pub jump: Option<Jump>,/// The composer, only where Cotton can really send. #[serde(default, skip_serializing_if = "Option::is_none")]pub composer: Option<ComposeAnswer>,/// Why there is no composer ("Read only: imported from WhatsApp"). #[serde(default, skip_serializing_if = "Option::is_none")]pub read_only: Option<String>,/// A stranger's request, until it is answered. #[serde(default, skip_serializing_if = "Option::is_none")]pub request: Option<RequestCard>,pub actions: ActionWords,/// The chat's disappearing timer, in a Cotton chat (chat-search): where it stands and its choices. #[serde(default, skip_serializing_if = "Option::is_none")]pub timer: Option<TimerCard>,/// While this phone's first pull runs and nothing of this chat has come/// yet: "Loading this chat…", said in place of an empty page. #[serde(default, skip_serializing_if = "Option::is_none")]pub loading: Option<String>,}// ── chat.compose ────────────────────────────────────────────────────────/// The composer's one button.#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "lowercase")]pubenumButton {/// Empty, and a voice message can be sent here.Mic,Send,/// Empty and no voice here: Send, dimmed.Idle,}#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "lowercase")]pubenumStripKind {Reply,Edit,}/// The strip above the field while a reply or an edit is in progress.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructStrip {pub kind: StripKind,pub message: String,pub title: String,pub line: String,pub cancel: String,}/// The sheet a poll is made on (chat CONTRACT.md "Making a poll"): its words only; the core checks what is sent.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructPollMaker {/// The attach sheet's row, and the sheet's title.pub label: String,pub question: String,pub option: String,pub add: String,/// The switch: more than one may be chosen.pub many: String,pub send: String,/// At most this many options (WhatsApp's 12).pub most: u32,}/// `chat.compose`: everything the shared composer (COMPOSER.md) is handed.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructComposeAnswer {pub thread: String,pub text: String,pub placeholder: String,pub button: Button,pub button_label: String,pub attach: bool,pub attach_label: String, #[serde(default, skip_serializing_if = "Option::is_none")]pub strip: Option<Strip>,/// The send rule: Send is live only with something to send.pub send_enabled: bool,/// The composer's microphone dictates into the text (Cotton's voice path).pub dictate: bool,pub dictate_label: String,/// The on-screen keyboard's Return makes a new line; a hardware/// keyboard's Return sends (Shift-Return a new line).pub return_sends: bool,pub hardware_return_sends: bool,/// Where this message goes (the header's `place`), drawn by the field before Send. #[serde(default, skip_serializing_if = "Option::is_none")]pub place: Option<PlaceMark>,/// A WhatsApp chat that takes a poll he makes (chat CONTRACT.md "Making a poll"): the words of its sheet. Absent/// where no poll can be made. #[serde(default, skip_serializing_if = "Option::is_none")]pub poll: Option<PollMaker>,/// A link in the words being written that this phone fetches a card for (chat CONTRACT.md "Link previews",/// FEEDBACK-4 B4): absent when previews are off here, the chat takes none, or there is no link. #[serde(default, skip_serializing_if = "Option::is_none")]pub preview: Option<PreviewAsk>,// No pick chip: Chat has none (the shared composer draws none when the// answer names none; Story's `story.scene` is the shape of one).}// ── chat.act ────────────────────────────────────────────────────────────/// Every act `chat.act` takes.pubconst ACTS: &[&str] = &["send", "react", "unreact", "edit", "delete", "pin", "unpin", "forward","read", "unread", "mute", "unmute", "archive", "unarchive", "pinChat", "unpinChat", "typing","deleteChat",// Acts on his WhatsApp itself, through the Mac: a person blocked there, and a chat deleted there for him alone// (owner, 24 Nov 2026; CONTRACT "Blocking a WhatsApp sender, deleting a WhatsApp chat")."blockOnWhatsApp", "deleteOnWhatsApp",// A failed message of the person's own put back in the outbox (20 Nov 2026)."retry",// A message starred or unstarred, the person's own; the chat's disappearing timer set (chat-search, 21 Nov 2026)."star", "unstar", "timer",// His vote on a WhatsApp poll, through the Mac (CONTRACT "Documents and votes", 23 Nov 2026)."vote",// A WhatsApp message deleted in his copy only, and a poll he makes there (CONTRACT "Editing and deleting his own// message", "Making a poll"; 23 Nov 2026)."deleteMine", "poll",// A voice message's transcript from the phone that recorded it, told after the message (FEEDBACK1 item 5, 22 Nov 2026)."transcript",// A voice message of theirs played a second on one of the person's phones: theirs alone, never told to the// sender (the voice player, 23 Nov 2026)."played",];/// `chat.act`. A send answers its bubble at once, before the network/// (`flush` says the shell should call `chat.flush` off the main thread).#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructActAnswer {pub ok: bool,pub act: String,pub thread: String, #[serde(default, skip_serializing_if = "Option::is_none")]pub message: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub bubble: Option<Bubble>, #[serde(default, skip_serializing_if = "Option::is_none")]pub row: Option<ListRow>,/// Forward: the conversations it went to. #[serde(default, skip_serializing_if = "Vec::is_empty")]pub sent_to: Vec<String>,pub flush: bool,/// A short line to toast ("Copied", "Pinned"). #[serde(default, skip_serializing_if = "Option::is_none")]pub said: Option<String>,}// ── chat.themes ─────────────────────────────────────────────────────────/// One theme as chat draws it: colours by token, for light and dark/// (`messages::app::themes::TOKENS`, plus `tint.<n>` and `name.<n>`).#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructChatTheme {pub id: String,pub name: String,/// Standing for the light or the dark appearance.pub on: bool,/// `plain` or a quiet pattern's id, drawn in the `pattern` colour.pub ground: String,pub light: BTreeMap<String, String>,pub dark: BTreeMap<String, String>,}#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructThemeWords {pub title: String,pub light: String,pub dark: String,/// Settings' own title.pub settings: String,}/// One choice of a Settings row (a text size, a thread ground).#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructChoice {pub id: String,pub label: String,/// A text size's scale over the phone's own size. #[serde(default, skip_serializing_if = "Option::is_none")]pub scale: Option<f64>,}/// A Settings row: its title, what is chosen, and the choices in order.#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructChoosing {pub title: String,pub chosen: String,pub options: Vec<Choice>,}/// `chat.themes` and `chat.theme.set`: every theme, and the one standing/// for each appearance (the phone's own pick, else the kit's default).#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructThemesAnswer {pub themes: Vec<ChatTheme>,pub light: String,pub dark: String,/// The thread's text size.pub text: Choosing,/// The thread's ground: `theme` (as the standing theme's `ground`), `plain` or `weave`.pub ground: Choosing,pub words: ThemeWords,}// ── search (`chat.search`, chat-search 21 Nov 2026) ─────────────────────/// One message a search found, as the results draw it.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructFoundMessage {pub thread: String,pub message: String,/// The chat's name, and its picture.pub name: String,pub picture: Picture,pub group: bool,/// Who wrote it: "You", or a member's name in a group; none for the other/// person of a one-to-one (the chat's name says it). #[serde(default, skip_serializing_if = "Option::is_none")]pub from: Option<String>,pub mine: bool,/// The words around the match, on one line, with "…" where cut …pub line: String,/// … and where the match stands in `line`, UTF-16 `[start, end)`.pub marks: Vec<[u32; 2]>,/// The time today, "Yesterday", else the day. #[serde(default, skip_serializing_if = "Option::is_none")]pub when: Option<String>,}#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructSearchWords {pub hint: String,pub chats: String,pub messages: String,pub more: String,}/// `chat.search { text }`: across every chat, chats by name first, then/// messages, newest first.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructSearchAnswer {/// The search as it was matched (trimmed, composed).pub text: String,/// Chats whose name holds it (a person's, a group's): only on the first page.pub chats: Vec<ListRow>,pub messages: Vec<FoundMessage>,/// Ask again with `after` for the next page of messages. #[serde(default, skip_serializing_if = "Option::is_none")]pub after: Option<String>,/// Said while this phone still reads its older messages into the index:/// what was found is real, and more may come. #[serde(default, skip_serializing_if = "Option::is_none")]pub older: Option<String>,/// "Nothing found for …" when there is nothing at all. #[serde(default, skip_serializing_if = "Option::is_none")]pub empty: Option<String>,pub words: SearchWords,}#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructInChatWords {pub hint: String,/// Toward older matches, and toward newer.pub earlier: String,pub later: String,}/// `chat.search { text, thread }`: the matches inside one chat.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructInChatAnswer {pub text: String,pub thread: String,/// Every match, newest first, at most [`COUNT_CEILING`]. The shell opens/// `hits[i]` with `chat.thread { thread, around: hits[i], find: text }`;/// "earlier" is `i + 1`, "later" is `i - 1`.pub hits: Vec<String>,/// `hits.len()`, said as a count ("999+" past the ceiling).pub count: String,/// "{i} of {n}" for each place: `places[i]` is said while `hits[i]` is open.pub places: Vec<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub older: Option<String>,/// "Not in this chat." when there is none. #[serde(default, skip_serializing_if = "Option::is_none")]pub empty: Option<String>,pub words: InChatWords,}// ── disappearing and starred (chat-search, 21 Nov 2026) ─────────────────/// One length a chat's timer can take.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructTimerChoice {pub seconds: u32,pub label: String,pub on: bool,}/// A conversation's disappearing timer (`chat.thread`'s `timer`): `chat.act { act: "timer", thread, seconds }` sets it.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructTimerCard {/// 0 when off.pub seconds: u32,/// "Disappearing messages".pub title: String,/// "Disappearing messages: 7 days" while on, for the header; none while off. #[serde(default, skip_serializing_if = "Option::is_none")]pub label: Option<String>,/// What it does, and what it cannot stop (a screenshot).pub note: String,/// Off, 24 hours, 7 days, 90 days; empty where the person cannot write in the chat.pub choices: Vec<TimerChoice>,}/// `chat.starred { after? }`: the person's starred messages, newest starred first.#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pubstructStarredAnswer {pub title: String,/// Each as a search result draws it, the whole message on its line, no marks.pub messages: Vec<FoundMessage>, #[serde(default, skip_serializing_if = "Option::is_none")]pub after: Option<String>, #[serde(default, skip_serializing_if = "Option::is_none")]pub empty: Option<String>,}