pub struct ByteStorage { /* private fields */ }Expand description
Raw byte storage engine (pure Rust core) Simple store/retrieve interface with no type awareness
Implementations§
Source§impl ByteStorage
impl ByteStorage
Sourcepub fn store(
&self,
data: &[u8],
format: Option<String>,
) -> Result<Vec<u8>, ByteStorageError>
pub fn store( &self, data: &[u8], format: Option<String>, ) -> Result<Vec<u8>, ByteStorageError>
Store arbitrary bytes with compression and checksums
Returns serialized StorageEnvelope bytes
Sourcepub fn retrieve(
&self,
envelope_bytes: &[u8],
) -> Result<(Vec<u8>, String), ByteStorageError>
pub fn retrieve( &self, envelope_bytes: &[u8], ) -> Result<(Vec<u8>, String), ByteStorageError>
Retrieve and validate stored bytes
Returns (original_data, format_identifier)
§Errors
envelope_bytes is untrusted. Before it is decoded, a structural
pre-scan bounds its nesting depth and rejects any header that declares
more than the input can back (protocol Retrieve Flow, step 2). A
pre-scan rejection is DeserializationFailed whose message starts with
decode pre-scan: , the same variant as any other bytes that do not
decode as a StorageEnvelope.
Sourcepub fn estimate_compression(&self, data: &[u8]) -> Result<f64, ByteStorageError>
pub fn estimate_compression(&self, data: &[u8]) -> Result<f64, ByteStorageError>
Get compression ratio for given data
Sourcepub fn validate(&self, envelope_bytes: &[u8]) -> bool
pub fn validate(&self, envelope_bytes: &[u8]) -> bool
Validate an envelope by fully extracting it and discarding the result
This runs StorageEnvelope::extract, so it decompresses the payload and
allocates up to the decompression bound. It is not a cheap structural
pre-screen for untrusted envelopes.
Sourcepub fn max_uncompressed_size(&self) -> usize
pub fn max_uncompressed_size(&self) -> usize
Get security limits