pub struct Deflate;Expand description
Raw deflate (RFC 1951) at level 6: Content-Encoding: deflate.
Output is byte for byte PHP’s gzdeflate($data, 6): the system’s zlib (the one PHP links)
at memory level 9. Decompressing accepts what gzinflate() accepts, including trailing
bytes after the stream, which are ignored.
use utopia_compression::{Algorithm, Deflate};
let deflate = Deflate::new();
assert_eq!(deflate.compress(b"a")?, b"\x4b\x04\x00");
assert_eq!(deflate.decompress(b"\x4b\x04\x00")?, b"a");use Utopia\Compression\Algorithms\Deflate;
$deflate = new Deflate();
echo bin2hex($deflate->compress('a')), "\n"; // 4b0400
echo $deflate->decompress("\x4b\x04\x00"), "\n"; // aRequires the zlib feature. PHP: Utopia\Compression\Algorithms\Deflate.
Implementations§
Source§impl Deflate
impl Deflate
Sourcepub const fn is_supported() -> bool
pub const fn is_supported() -> bool
Whether this build has zlib (the zlib feature).
PHP: Deflate::isSupported(), whether gzdeflate() 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 Deflate
impl Algorithm for Deflate
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 Deflate
impl Eq for Deflate
impl StructuralPartialEq for Deflate
Auto Trait Implementations§
impl Forget for Deflate
impl Freeze for Deflate
impl Move for Deflate
impl RefUnwindSafe for Deflate
impl Send for Deflate
impl Sync for Deflate
impl Unpin for Deflate
impl UnsafeUnpin for Deflate
impl UnwindSafe for Deflate
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.