pub enum ByteCodec {
None,
Deflate,
Gzip,
Brotli,
ZstdDict(Arc<ZstdDictionary>),
}Expand description
Byte-level compression algorithms used by SecureCompressor.
This is distinct from CompressionStrategy, which operates on
serde_json::Value (Layer A). ByteCodec operates on raw bytes after JSON serialization
(Layer B).
Codecs other than None require the compression feature.
§Breaking change (pre-1.0)
Copy was removed from this enum when ZstdDict was added (it carries an
Arc<ZstdDictionary>). Code that relied on implicit copy can use .clone()
(one atomic refcount bump for ZstdDict; a no-op for the other variants).
Variants§
None
No compression — bytes stored verbatim. Always available.
Deflate
Raw deflate (RFC 1951). Low framing overhead.
Note: raw deflate has no magic header, so codec mismatch during decompression will
produce a decoder error rather than a guaranteed clean failure. The codec tag embedded
in SecureCompressedData prevents this for in-process round-trips.
Requires feature = "compression".
Gzip
Gzip (RFC 1952). Self-identifying via 1f 8b magic header.
Requires feature = "compression".
Brotli
Brotli. Best ratio for repetitive JSON.
Requires feature = "compression".
ZstdDict(Arc<ZstdDictionary>)
Trained zstd dictionary compression.
A single Arc<ZstdDictionary> is the canonical sharing primitive. The inner
Vec<u8> inside crate::compression::zstd::ZstdDictionary is not
Arc-wrapped — sharing happens exactly once at this enum level (avoids
double indirection). Cloning this variant performs one atomic refcount
increment and no allocation.
Equality compares the underlying bytes via Arc<T>: PartialEq where T: PartialEq.
When both sides share the same Arc allocation, Arc::ptr_eq provides a fast path.
Requires feature = "compression" on a non-wasm32 target.
Trait Implementations§
impl Eq for ByteCodec
impl StructuralPartialEq for ByteCodec
Auto Trait Implementations§
impl Freeze for ByteCodec
impl RefUnwindSafe for ByteCodec
impl Send for ByteCodec
impl Sync for ByteCodec
impl Unpin for ByteCodec
impl UnsafeUnpin for ByteCodec
impl UnwindSafe for ByteCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more