//! Reader limits the extension formats share with SPEC §2.
//!
//! A score, haptic signal or audio scene declares how many samples it renders, and a
//! splat4d clip, film or reel how many frames; rendering allocates in proportion. Each
//! extension's reader refuses a contract past these limits when it reads the contract
//! (`duration_too_long`), before anything is rendered, as SPEC §2 does for audio and
//! video payloads.

/// The most samples, counting every channel, a reader must be willing to render from
/// one object: 2^27, the audio limit of SPEC §2 (46 minutes of one channel at 48 kHz).
pub const RENDER_MAX_SAMPLES: u64 = 1 << 27;

/// The most frames a reader must be willing to render from one object: 2^20, the
/// video limit of SPEC §2 (4.9 hours at 60 frames a second).
pub const RENDER_MAX_FRAMES: u64 = 1 << 20;

/// The refusal for a contract past either limit, as its message.
pub fn duration_too_long(what: &str, declared: u64, limit: u64) -> String {
    format!("duration_too_long: the contract declares {what} {declared}, past the {limit} a reader need render")
}
