//! A LIST'S CARD (owner, 7 Nov 2026: Music's list of songs is a cassette,//! first on its own deck): what the card of one `record_group` holds, as the//! deck answers it (`shell.deck`) for a tool whose lists stand in a face of//! their own (`ToolDefinition::lists`). The face draws from these places//! alone://!//! - `title`: the list's name;//! - `songs`: its members in the list's own order (`group_member.place`),//! each its `record`, `title`, `subtitle`, `photo`, its length in seconds//! (`duration`) and the recording it plays (`play`) — or `unavailable`;//! - `count`: how many, said ("5 songs", "1 song");//! - `length`: every member's length added, as a player's clock ("19:18",//! "3:44:20"), absent while the list is empty;//! - `photo`: the list's own picture (`record_group.picture`), else the//! first member's that has one (a song's album cover), else none.//!//! The stripes a cassette is dyed with are read off `photo` on the phone,//! as a song's are off its cover (pixels are the phone's).use serde_json::{json, Map, Value};usecrate::records::page::clock_said;usecrate::rules::shell_lines::{self, LineRow};/// One member of a list as its card reads it.#[derive(Debug, Clone, Default, PartialEq)]pubstructMember {pub record: String,pub title: Option<String>,pub subtitle: Option<String>,pub photo: Option<String>,/// The member's length, in seconds.pub seconds: f64,/// The recording it plays; none, it cannot be played.pub play: Option<String>,}/// The places of a list's card (see the module's header), its members in/// the order given.pubfn places(name: &str, picture: Option<&str>, members: &[Member], lines: &[LineRow]) -> Map<String, Value> {letmut places = Map::new(); places.insert("title".into(), json!(name));let songs: Vec<Value> = members.iter().map(|member| {letmut entry = json!({"record": member.record, "duration": member.seconds.max(0.0)});for (slot, words) in [("title", &member.title), ("subtitle", &member.subtitle), ("photo", &member.photo)] {ifletSome(words) = words.as_deref().map(str::trim).filter(|words| !words.is_empty()) { entry[slot] = json!(words); } }match member.play.as_deref().filter(|file| !file.is_empty()) {Some(file) => entry["play"] = json!(file),None => entry["unavailable"] = json!(true), } entry }).collect(); places.insert("songs".into(), Value::Array(songs));let n = members.len().to_string();let count = if members.len() == 1 { "cassette.song" } else { "cassette.songs" };ifletSome(said) = shell_lines::resolve("cards", count, lines, &[("n", &n)]) { places.insert("count".into(), json!(said)); }let whole: f64 = members.iter().map(|member| member.seconds.max(0.0)).sum();if !members.is_empty() {ifletSome(clock) = clock_said(whole) { places.insert("length".into(), json!(clock)); } }let own = picture.map(str::trim).filter(|key| !key.is_empty());let first = members.iter().find_map(|member| member.photo.as_deref().map(str::trim).filter(|key| !key.is_empty()));ifletSome(photo) = own.or(first) { places.insert("photo".into(), json!(photo)); } places}#[cfg(test)]#[path = "list_card_tests.rs"]mod tests;