//! His choices on a photo, Albums' Bin, and Free (DECISIONS.md question 3a; //! the coordinator's decision G, 27 Nov 2026: one Bin on both phones). //! //! - **Keep:** stays, and Albums stops offering it in any list or set. //! - **Bin:** gone from every list, set and album view at once, undoable. //! On **both phones** it is a mark in Albums' own Bin and touches nothing in //! the library: no clock can take what waits there. Nothing leaves the //! library until he taps Delete in the Bin, which asks the phone with the //! ids on screen, each checked again at that moment ([`free_batches`]): the //! iPhone's `deleteAssets` (then Photos' Recently Deleted for 30 days), //! Android's `createTrashRequest` (then the phone's own trash for 30 days). //! - **Handed:** in a Delete waiting for the phone (ALBUMS CORE 1d). Nothing //! acts on it; only a read of the library settles it ([`settled`]): gone or //! in the phone's trash, freed; still there, back in the Bin. The shell //! never says what happened, so the core never assumes the system dialog //! was accepted (the ProRAW bug where the answer never comes, RESEARCH.md §1), //! and a kill anywhere heals at the next read. //! - **Freed:** the library no longer shows it as present after Delete. //! Albums can no longer bring it back; Photos (or the phone's trash) can, //! for 30 days, and a read that finds it present again makes it an //! ordinary kept photo. use serde::{Deserialize, Serialize}; use super::Platform; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(tag = "mark", rename_all = "snake_case")] pub enum Mark { None, Keep { at_ms: i64 }, Bin { at_ms: i64 }, /// Handed to the phone by a Delete that waits for the library to say what /// happened (ALBUMS CORE 1d): no act touches it until a library read /// settles it ([`settled`]). Handed { at_ms: i64, /// Only [`super::handing::free_plan`] makes one (decision M-b); a /// stored one is decoded. #[serde(skip, default = "super::handing::Seal::decoded")] seal: super::handing::Seal, }, Freed { at_ms: i64 }, } impl Mark { pub fn offered(&self) -> bool { matches!(self, Mark::None) } pub fn in_bin(&self) -> bool { matches!(self, Mark::Bin { .. }) } pub fn handed(&self) -> bool { matches!(self, Mark::Handed { .. }) } } /// Android: at most 2,000 items a request (Android 16, RESEARCH.md §3). pub const ANDROID_BATCH: usize = 2_000; /// iPhone: no documented limit; one alert a call, so one call for up to this /// many and more calls (each its own alert, said before) only beyond it. pub const IOS_BATCH: usize = 10_000; /// After Delete, the phone's own bin keeps an item this long (Photos' Recently /// Deleted, Android's trash). Albums' Bin keeps until Delete, on both phones. pub const PHONE_BIN_DAYS: i64 = 30; /// Split the items to free into the requests the phone makes, one system /// confirmation each. pub fn free_batches(platform: Platform, ids: &[String]) -> Vec> { let size = match platform { Platform::Ios => IOS_BATCH, Platform::Android => ANDROID_BATCH, }; ids.chunks(size).map(<[String]>::to_vec).collect() } /// An item's one library state, only ever from the shell's reads of the /// library (ALBUMS CORE 1d): in it, in the phone's trash (Android's trashed /// flag; iOS Recently Deleted where readable), or not there at all. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum LibraryState { Present, Trashed, Absent, } impl LibraryState { pub const ALL: [LibraryState; 3] = [LibraryState::Present, LibraryState::Trashed, LibraryState::Absent]; pub fn key(self) -> &'static str { match self { LibraryState::Present => "present", LibraryState::Trashed => "trashed", LibraryState::Absent => "absent", } } pub fn from_key(k: &str) -> Option { match k { "present" => Some(LibraryState::Present), "trashed" => Some(LibraryState::Trashed), "absent" => Some(LibraryState::Absent), _ => None, } } } /// What a handed item becomes once the library has been read: gone into the /// phone's trash or gone altogether, freed; still there, back in the Bin. The /// shell's own say-so never settles it. pub fn settled(state: LibraryState, at_ms: i64) -> Mark { match state { LibraryState::Present => Mark::Bin { at_ms }, LibraryState::Trashed | LibraryState::Absent => Mark::Freed { at_ms }, } } /// Whether Albums can still bring an item back: anything in its Bin, on /// both phones, for as long as it waits there. pub fn can_bring_back(mark: &Mark) -> bool { matches!(mark, Mark::Bin { .. }) }