Cotton code
55 lines · 2.1 KB · RustRaw
//! MAIL PREDICATE (the coordinator, 26 Nov 2026): the one place that says, in SQL, whether a mail (or a//! conversation) is live, binned, unread or read. Every reader of a person's mail asks here (Post, Comms, Days, search,//! the assistant's tools on the phone and on the Worker), never spelling `trashed_at` or `unread` itself, so a later//! way of binning or reading many mails at once (one row for a whole act, as Archive's `email_cut`) changes this file//! and every reader follows.//!//! Each takes `on`, the prefix of the mail's columns in the query: `""`, `"e."`, `"cotton_emails."`. The answer is a//! parenthesised SQL condition with no parameters, so it drops into any `WHERE` beside the caller's own `?`s. Each//! keeps the spelling the store's partial indexes are written against (`trashed_at IS NULL` in//! `idx_cotton_emails_inbox`, `_files`, `_archived`; `unread = 1`), so the planner still finds them.//!//! Writers (the acts that set `trashed_at` or `unread`) are not readers and do not come here./// A mail that is not in the Bin: neither its own `trashed_at` nor a Delete of its sender ([`cuts`], phase 2).pub fn live(on: &str) -> String {    cuts::live(on)}/// A mail in the Bin.pub fn binned(on: &str) -> String {    cuts::binned(on)}/// A mail not yet read: its own `unread` (written 0 or 1) and no Mark read of many.pub fn unread(on: &str) -> String {    cuts::unread(on)}/// A mail read.pub fn read(on: &str) -> String {    cuts::read(on)}/// A conversation not in the Bin: one of its mails is live (derived, never its stored `trashed_at`).pub fn live_thread(on: &str) -> String {    cuts::live_thread(on)}/// A conversation in the Bin: it holds opened mail and none is live.pub fn binned_thread(on: &str) -> String {    cuts::binned_thread(on)}/// When a mail went to the Bin: its own `trashed_at`, else its Delete's moment.pub fn binned_at(on: &str) -> String {    cuts::binned_at(on)}/// A live mail an Archive of its sender covers.pub fn archived(on: &str) -> String {    cuts::archived(on)}#[path = "cuts.rs"]pub mod cuts;