//! Bytes: where this Mac keeps them, and how they leave. //! //! Two halves, and they are deliberately separate. [`store`] is the device's own //! content-addressed copy — permanent, never evicted, the thing that makes an //! import work with the network off. [`drain`] is the ledger walking those bytes //! up to the bucket in the background, for ever, with a backoff and no attempt //! ceiling. //! //! [`transport`] is the third: the person's object's media door, which the //! drain puts through (`PUT /v1/media/`, or the file in parts) and the //! hydrator reads through (`GET /v1/media/`). //! //! [`evict`] is the fifth, and it is the only one that DELETES: the budgeted //! phone cache, taking viewed originals off this device least-recently-viewed //! first when the media store outgrows what the person allows it. **Never a //! thumbnail, never a capture this device made, and never the last copy of //! anything.** //! //! What is NOT here: a path answered ACROSS the boundary. A read answers a //! PATH and Swift reads the file itself (design M4) — no renderer, no scheme, //! no bytes across the FFI boundary at all. /// The keys the object answered 404 for, waiting before they are asked again. pub mod absent; pub mod drain; /// The BUDGET: viewed originals leaving this device to make room, never a /// thumbnail and never the last copy of anything. pub mod evict; pub mod fetching; pub mod storage; /// The mirror image of the drain: originals coming DOWN, until two live devices /// hold each one. pub mod hydrate; pub mod keep_fetch; pub mod network; /// A person's own files sealed going up and opened coming down (R6). pub mod sealed; /// A sealed file read where the object keeps it, a range at a time (R6). pub mod remote; /// The phone's own player door: a sealed file opened as it plays (R6). pub mod lan; pub mod loopback; /// This device's own holds, named by its device key. pub mod holds; pub mod store; pub mod transport; /// The bytes of erased records leaving this device (slice 7). pub mod unlink; /// A copy of a Photos original leaving once the object holds it (KEEP 1e). pub mod release; /// Where each queued file is: the ledger's answer and the uploads in the air. pub mod uploads; pub use uploads::{uploads_of, FileUpload, Flight, Phase, UploadCounts, UploadWatch, Uploads}; pub use drain::{ carry_bytes, carry_bytes_watched, refusal_code, Progress, counts_of, drain_pass, finish_upload, is_dead_key_refusal, is_terminal_refusal, plan_upload, DrainPass, DrainState, Landed, MediaDrain, MediaDrainDeps, MediaDrainInput, MediaDrainStatus, MediaMoved, MediaMovedListener, UploadPlan, Uploaded, MEDIA_DRAIN_BATCH, MEDIA_DRAIN_CONCURRENCY, MEDIA_DRAIN_INTERVAL_MS, }; pub use evict::{ evict_pass, read_budget, set_budget, EvictPass, EvictSweep, OtherReplicas, MediaEvictDeps, StoredBudget, SystemEvictDisk, EVICT_BATCH, MEDIA_BUDGET_CHOICES, MEDIA_BUDGET_DEFAULT_BYTES, THUMB_CEILING_BYTES, THUMB_CEILING_WARNING, }; pub use hydrate::{ free_bytes_at, hydrate_every, hydrate_pass, room_left, work_list, DiskRoom, HydratePass, MediaHydrateDeps, Policy, DISK_UNREAD, HYDRATE_BATCH, HYDRATE_DISK_FLOOR_BYTES, REPLICATION_HOLDERS, }; pub use store::{file_size_of, media_file_path, put_media_file, sha256_file, StoredMediaFile}; pub use unlink::{bytes_are_dead, objects_of_dead_key, unlink_pass, UnlinkPass, UnlinkSweep}; pub use transport::{ObjectMediaTransport, StreamGrant, PART_BYTES}; /// Thumbnail query shapes derived from the canonical key builders. pub fn thumb_key_shapes(file: &cotton_store::file_identity::FileId) -> (cotton_store::media_thumbs::KeyShape, cotton_store::media_thumbs::KeyShape) { use cotton_core::media::keys::{photo_thumb_key, video_thumb_key}; use cotton_store::media_thumbs::KeyShape; let sentinel = "0".repeat(64); let split = |key: String| { let (prefix, suffix) = key.split_once(&sentinel).expect("thumbnail key contains its digest"); KeyShape::new(prefix, suffix) }; (split(photo_thumb_key(file, &sentinel)), split(video_thumb_key(file, &sentinel))) }