oxabl_cache_format/
limits.rs1use crate::error::{FormatError, Result};
4
5pub const LOOKUP_IDS: usize = 10_000;
7pub const SAMPLE_IDS: usize = 1_000;
9pub const COMMIT_ENTRIES: usize = 2_000;
11pub const PACK_SEGMENTS: usize = 2_000;
13pub const PACK_BYTES: u64 = 32 * 1024 * 1024;
15pub const FILES_PER_SET: usize = 16;
17pub const PATH_BYTES: usize = 1_024;
19pub const SET_PATH_BYTES: usize = 3_072;
21pub const SEALED_RECORD_BYTES: usize = 4_096;
23pub const RECORD_ALIGN: usize = 256;
25pub const DEFAULT_PLAINTEXT_BYTES: u64 = 64 * 1024 * 1024;
27pub const MAX_PLAINTEXT_BYTES: u64 = 1024 * 1024 * 1024;
29pub const ROSTER_BYTES: usize = 1024 * 1024;
31pub const ROSTER_MEMBERS: usize = 1_000;
33pub const ROSTER_SIGNATURES: usize = 4;
35pub const BECH32_CHARS: usize = 1_024;
37pub const TELEMETRY_BYTES: usize = 1_024;
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
42pub struct Limits {
43 plaintext_bytes: u64,
44}
45
46impl Limits {
47 pub fn new(plaintext_bytes: u64) -> Result<Self> {
49 if plaintext_bytes > MAX_PLAINTEXT_BYTES {
50 return Err(FormatError::LimitExceeded("plaintext per artifact set"));
51 }
52 Ok(Self { plaintext_bytes })
53 }
54
55 pub fn plaintext_bytes(&self) -> u64 {
57 self.plaintext_bytes
58 }
59}
60
61impl Default for Limits {
62 fn default() -> Self {
63 Self {
64 plaintext_bytes: DEFAULT_PLAINTEXT_BYTES,
65 }
66 }
67}