Skip to main content

DxCompressed

Struct DxCompressed 

Source
pub struct DxCompressed { /* private fields */ }
Expand description

Compressed DX-Machine buffer

Wraps compressed data with lazy decompression. The first access triggers decompression, subsequent accesses use cache.

Implementations§

Source§

impl DxCompressed

Source

pub fn new() -> Self

Create empty compressed buffer

Source

pub fn compress(data: &[u8]) -> Self

Compress data using LZ4 (fast, pure Rust)

LZ4 provides good compression with excellent speed (pure Rust, no C dependencies).

Source

pub fn compress_level(data: &[u8], _level: CompressionLevel) -> Self

Compress with level hint

Source

pub fn compressed_size(&self) -> usize

Get compressed size

Source

pub fn original_size(&self) -> usize

Get original (uncompressed) size

Source

pub fn ratio(&self) -> f64

Get compression ratio (compressed / original)

Source

pub fn savings(&self) -> f64

Get space savings (1.0 - ratio)

Source

pub fn as_compressed(&self) -> &[u8]

Get compressed bytes

Source

pub fn decompress(&mut self) -> Result<&[u8]>

Decompress and get data

First call triggers decompression, subsequent calls use cache.

Source

pub fn decompress_owned(&self) -> Result<Vec<u8>>

Force decompress and return owned data

Source

pub fn is_cached(&self) -> bool

Check if already decompressed (cached)

Source

pub fn clear_cache(&mut self)

Clear the decompression cache

Source

pub fn from_compressed(compressed: Vec<u8>, original_size: u32) -> Self

Create from pre-compressed data

Source

pub fn to_wire(&self) -> Vec<u8>

Serialize to wire format: [compressed_data_with_prepended_size...]

Source

pub fn from_wire(data: &[u8]) -> Result<Self>

Parse from wire format

Trait Implementations§

Source§

impl Debug for DxCompressed

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DxCompressed

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.