pub struct Xz;Expand description
XZ: LZMA2 at preset 5 in an .xz container with a CRC64 check.
The settings are those of PHP’s ext-xz xzencode() (its default
xz.compression_level of 5); decompressing reads concatenated .xz
streams.
use utopia_compression::{Algorithm, Xz};
let xz = Xz::new();
match xz.compress(b"This is a demo string") {
Ok(body) => assert_eq!(xz.decompress(&body)?, b"This is a demo string"),
// Built without the `xz` feature.
Err(e) => assert_eq!(e.php_class(), "Error"),
}use Utopia\Compression\Algorithms\XZ;
$xz = new XZ();
if (XZ::isSupported()) {
echo $xz->decompress($xz->compress('This is a demo string')), "\n"; // This is a demo string
}Requires the xz feature, which is off by default: without it, as in
PHP without ext-xz, compress() and decompress() fail with
Error::Unsupported. Output is not compared with PHP’s: the PHP image
the conversion is checked against has no ext-xz.
PHP: Utopia\Compression\Algorithms\XZ.
Implementations§
Trait Implementations§
Source§impl Algorithm for Xz
impl Algorithm for Xz
Source§fn decompress(&self, data: &[u8]) -> Result<Vec<u8>, Error>
fn decompress(&self, data: &[u8]) -> Result<Vec<u8>, Error>
Decompresses
data. Fails with Error::Codec when data is not a
valid stream of the algorithm. Read moreimpl Copy for Xz
impl Eq for Xz
impl StructuralPartialEq for Xz
Auto Trait Implementations§
impl Forget for Xz
impl Freeze for Xz
impl Move for Xz
impl RefUnwindSafe for Xz
impl Send for Xz
impl Sync for Xz
impl Unpin for Xz
impl UnsafeUnpin for Xz
impl UnwindSafe for Xz
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> 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
Compare self to
key and return true if they are equal.