pub struct L2BlobCompressor;Expand description
Stateless compressor for L2 blob payloads.
All methods are associated functions; the type carries no data and is unconstructible at runtime. It exists purely as a namespace and to keep the public surface in one place.
Implementations§
Source§impl L2BlobCompressor
impl L2BlobCompressor
Sourcepub fn compress(
bytes: &[u8],
content_type: Option<&str>,
opts: &CompressOpts,
) -> Result<Compressed, CompressError>
pub fn compress( bytes: &[u8], content_type: Option<&str>, opts: &CompressOpts, ) -> Result<Compressed, CompressError>
Compress bytes, honouring the skip rules in CompressOpts and the
content_type hint.
§Skip rules
bytes.len() < opts.min_bytes→ returnsCompressed::Raw.content_typematches a pre-compressed media bucket (see [is_precompressed_media]) → returnsCompressed::Raw.- The encoded payload would be
>= bytes.len() * opts.max_ratio→ returnsCompressed::Raw.
§Errors
CompressError::OversizeOriginalifbytes.len() > u32::MAX.CompressError::ZstdEncodeif the underlying encoder fails.
Sourcepub fn decompress(c: &Compressed) -> Result<Vec<u8>, CompressError>
pub fn decompress(c: &Compressed) -> Result<Vec<u8>, CompressError>
Decompress a previously-stored Compressed payload back to the
original byte slice.
§Errors
CompressError::ZstdDecodeif the encoded bytes are malformed or if the decoded length does not match the recordedoriginal_len.
Auto Trait Implementations§
impl Freeze for L2BlobCompressor
impl RefUnwindSafe for L2BlobCompressor
impl Send for L2BlobCompressor
impl Sync for L2BlobCompressor
impl Unpin for L2BlobCompressor
impl UnsafeUnpin for L2BlobCompressor
impl UnwindSafe for L2BlobCompressor
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request