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;
37
38#[derive(Debug, Clone, Copy, PartialEq, Eq)]
40pub struct Limits {
41 plaintext_bytes: u64,
42}
43
44impl Limits {
45 pub fn new(plaintext_bytes: u64) -> Result<Self> {
47 if plaintext_bytes > MAX_PLAINTEXT_BYTES {
48 return Err(FormatError::LimitExceeded("plaintext per artifact set"));
49 }
50 Ok(Self { plaintext_bytes })
51 }
52
53 pub fn plaintext_bytes(&self) -> u64 {
55 self.plaintext_bytes
56 }
57}
58
59impl Default for Limits {
60 fn default() -> Self {
61 Self {
62 plaintext_bytes: DEFAULT_PLAINTEXT_BYTES,
63 }
64 }
65}