soma_codemode/state/
quota.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub struct WorkspaceQuota {
3 pub max_bytes: u64,
4}
5
6impl Default for WorkspaceQuota {
7 fn default() -> Self {
8 Self {
9 max_bytes: 32 * 1024 * 1024,
10 }
11 }
12}
13
14impl WorkspaceQuota {
15 pub fn check(self, used: u64, new_bytes: u64) -> bool {
16 used.saturating_add(new_bytes) <= self.max_bytes
17 }
18}
19
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21pub struct StateWorkspaceLimits {
22 pub max_file_bytes: usize,
23 pub max_total_bytes: u64,
24 pub max_entries: u64,
25 pub max_result_bytes: usize,
26}
27
28impl Default for StateWorkspaceLimits {
29 fn default() -> Self {
30 Self {
31 max_file_bytes: 1024 * 1024,
32 max_total_bytes: 64 * 1024 * 1024,
33 max_entries: 10_000,
34 max_result_bytes: 1024 * 1024,
35 }
36 }
37}