mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-30 00:28:13 +00:00
compression: deflate: move encoder into a mod
This allows to add a decompression mod inside the deflate mod. This does not touch the public API. Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com> Reviewed-by: Max Carrara <m.carrara@proxmox.com> Tested-by: Max Carrara <m.carrara@proxmox.com>
This commit is contained in:
parent
7ae351854e
commit
70a71e0c8e
@ -12,8 +12,6 @@ use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
|
|||||||
use proxmox_io::ByteBuffer;
|
use proxmox_io::ByteBuffer;
|
||||||
use proxmox_lang::io_format_err;
|
use proxmox_lang::io_format_err;
|
||||||
|
|
||||||
const BUFFER_SIZE: usize = 8192;
|
|
||||||
|
|
||||||
pub enum Level {
|
pub enum Level {
|
||||||
Fastest,
|
Fastest,
|
||||||
Best,
|
Best,
|
||||||
@ -53,7 +51,7 @@ impl<T> DeflateEncoder<T> {
|
|||||||
Self {
|
Self {
|
||||||
inner,
|
inner,
|
||||||
compressor: Compress::new(level, false),
|
compressor: Compress::new(level, false),
|
||||||
buffer: ByteBuffer::with_capacity(BUFFER_SIZE),
|
buffer: ByteBuffer::with_capacity(super::BUFFER_SIZE),
|
||||||
input_buffer: Bytes::new(),
|
input_buffer: Bytes::new(),
|
||||||
state: EncoderState::Reading,
|
state: EncoderState::Reading,
|
||||||
}
|
}
|
||||||
@ -109,7 +107,7 @@ impl<T: AsyncWrite + Unpin> DeflateEncoder<T> {
|
|||||||
where
|
where
|
||||||
R: AsyncRead + Unpin,
|
R: AsyncRead + Unpin,
|
||||||
{
|
{
|
||||||
let mut buffer = ByteBuffer::with_capacity(BUFFER_SIZE);
|
let mut buffer = ByteBuffer::with_capacity(super::BUFFER_SIZE);
|
||||||
let mut eof = false;
|
let mut eof = false;
|
||||||
loop {
|
loop {
|
||||||
if !eof && !buffer.is_full() {
|
if !eof && !buffer.is_full() {
|
5
proxmox-compression/src/deflate/mod.rs
Normal file
5
proxmox-compression/src/deflate/mod.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
mod compression;
|
||||||
|
|
||||||
|
pub use compression::{DeflateEncoder, Level};
|
||||||
|
|
||||||
|
const BUFFER_SIZE: usize = 8192;
|
@ -1,8 +1,8 @@
|
|||||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||||
|
|
||||||
mod compression;
|
pub use deflate::{DeflateEncoder, Level};
|
||||||
pub use compression::*;
|
|
||||||
|
|
||||||
|
mod deflate;
|
||||||
pub mod tar;
|
pub mod tar;
|
||||||
pub mod zip;
|
pub mod zip;
|
||||||
pub mod zstd;
|
pub mod zstd;
|
||||||
|
@ -22,7 +22,7 @@ use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf};
|
|||||||
use crc32fast::Hasher;
|
use crc32fast::Hasher;
|
||||||
use proxmox_time::gmtime;
|
use proxmox_time::gmtime;
|
||||||
|
|
||||||
use crate::compression::{DeflateEncoder, Level};
|
use crate::deflate::{DeflateEncoder, Level};
|
||||||
|
|
||||||
const LOCAL_FH_SIG: u32 = 0x04034B50;
|
const LOCAL_FH_SIG: u32 = 0x04034B50;
|
||||||
const LOCAL_FF_SIG: u32 = 0x08074B50;
|
const LOCAL_FF_SIG: u32 = 0x08074B50;
|
||||||
|
Loading…
Reference in New Issue
Block a user