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