agentics_storage/
intent.rs1use crate::{Result, StorageError};
2
3#[derive(Debug, Clone, Copy)]
5pub struct StorageWriteIntent {
6 label: &'static str,
7 max_bytes: u64,
8}
9
10impl StorageWriteIntent {
11 pub const fn new(label: &'static str, max_bytes: u64) -> Self {
13 Self { label, max_bytes }
14 }
15
16 pub const fn label(self) -> &'static str {
18 self.label
19 }
20
21 pub const fn max_bytes(self) -> u64 {
23 self.max_bytes
24 }
25
26 pub fn ensure_len(self, actual: u64) -> Result<()> {
28 if actual > self.max_bytes {
29 return Err(StorageError::ObjectTooLarge {
30 label: self.label,
31 actual,
32 limit: self.max_bytes,
33 });
34 }
35 Ok(())
36 }
37}