pub struct Lz4 { /* private fields */ }Expand description
LZ4 blocks with ext-lz4’s framing: the uncompressed size as a 4-byte little-endian prefix, then one LZ4 block.
Level 0 (the default) is LZ4’s fast mode; levels 1 to 12 are its high
compression (HC) mode. Output is byte for byte PHP’s lz4_compress()
(LZ4 1.10.0).
use utopia_compression::{Algorithm, Lz4};
let lz4 = Lz4::new();
let body = lz4.compress(b"This is a demo string")?;
assert_eq!(body.len(), 27);
assert_eq!(lz4.decompress(&body)?, b"This is a demo string");use Utopia\Compression\Algorithms\LZ4;
$lz4 = new LZ4();
$body = $lz4->compress('This is a demo string');
echo strlen($body), "\n"; // 27
echo $lz4->decompress($body), "\n"; // This is a demo stringRequires the lz4 feature. PHP: Utopia\Compression\Algorithms\LZ4.
Implementations§
Source§impl Lz4
impl Lz4
Sourcepub const fn with_level(level: i64) -> Self
pub const fn with_level(level: i64) -> Self
LZ4 at level, unchecked: a level outside 0 to 12 makes
Algorithm::compress fail with Error::Codec, as in PHP.
PHP: new LZ4($level).
Sourcepub const fn level(&self) -> i64
pub const fn level(&self) -> i64
The level: 0 for fast mode, 1 to 12 for high compression.
PHP: getLevel().
Sourcepub fn set_level(&mut self, level: i64) -> Result<(), Error>
pub fn set_level(&mut self, level: i64) -> Result<(), Error>
Sets the level. Fails with Error::InvalidArgument outside 0 to
12.
PHP: setLevel($level).
Sourcepub const fn is_supported() -> bool
pub const fn is_supported() -> bool
Whether this build has LZ4 (the lz4 feature).
PHP: LZ4::isSupported(), whether lz4_compress() exists.
Sourcepub fn compress_into<S: Sink + ?Sized>(
&self,
data: &[u8],
out: &mut S,
) -> Result<(), Error>
pub fn compress_into<S: Sink + ?Sized>( &self, data: &[u8], out: &mut S, ) -> Result<(), Error>
Algorithm::compress, appended to out.
Sourcepub fn decompress_into<S: Sink + ?Sized>(
&self,
data: &[u8],
out: &mut S,
) -> Result<(), Error>
pub fn decompress_into<S: Sink + ?Sized>( &self, data: &[u8], out: &mut S, ) -> Result<(), Error>
Algorithm::decompress, appended to out.
Trait Implementations§
Source§impl Algorithm for Lz4
impl Algorithm for Lz4
Source§fn decompress(&self, data: &[u8]) -> Result<Vec<u8>, Error>
fn decompress(&self, data: &[u8]) -> Result<Vec<u8>, Error>
data. Fails with Error::Codec when data is not a
valid stream of the algorithm. Read moreimpl Copy for Lz4
impl Eq for Lz4
impl StructuralPartialEq for Lz4
Auto Trait Implementations§
impl Forget for Lz4
impl Freeze for Lz4
impl Move for Lz4
impl RefUnwindSafe for Lz4
impl Send for Lz4
impl Sync for Lz4
impl Unpin for Lz4
impl UnsafeUnpin for Lz4
impl UnwindSafe for Lz4
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.