Cotton code
27 lines · 1.2 KB · RustRaw
//! Who wrote a record, as a reading: the name an assistant writes under, or//! nothing.//!//! A record stamps its writer as a kind (`user` or `agent`) and a label — the//! connection's name, which for Cotton's own work is an actor's wire id//! (`job:synthetic`, `import:…`). A person's own record carries no byline and//! no review loop, and a writer's id is never shown (walker pass 3: Notes and//! Journal read "Written by job:synthetic" under a diary entry, with "Comment//! to ask for another look"). So only an assistant's name is a writer; the//! person, and Cotton's own jobs, imports and devices, are nobody to name.use crate::rules::history::trail::actor_role;/// The writer's name to show for a record stamped `kind` / `label`: the/// label when an assistant wrote it under a name, else nothing — the/// person's own record, an unnamed writer, or a label that is an actor's id.pub fn writer_name(kind: Option<&str>, label: Option<&str>) -> Option<String> {    if kind != Some("agent") {        return None;    }    let label = label.map(str::trim).filter(|label| !label.is_empty())?;    (actor_role(label) == "local").then(|| label.to_string())}#[cfg(test)]#[path = "writer_tests.rs"]mod tests;