-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust: start to implement ZstdCompressor.stream_writer()
I started to implemented this type then quickly found myself blocked on PyO3/pyo3#1205 / PyO3/pyo3#1206 due to not being able to return `Self` from `__enter__`. We'll have to wait for a future pyo3 release before we can finish the Rust port.
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2020-present, Gregory Szorc | ||
// All rights reserved. | ||
// | ||
// This software may be modified and distributed under the terms | ||
// of the BSD license. See the LICENSE file for details. | ||
|
||
use {crate::compressor::CCtx, pyo3::prelude::*, std::sync::Arc}; | ||
|
||
#[pyclass] | ||
pub struct ZstdCompressionWriter { | ||
cctx: Arc<CCtx<'static>>, | ||
writer: PyObject, | ||
source_size: u64, | ||
write_size: usize, | ||
write_return_read: bool, | ||
closefd: bool, | ||
entered: bool, | ||
closing: bool, | ||
closed: bool, | ||
bytes_compressed: usize, | ||
} | ||
|
||
impl ZstdCompressionWriter { | ||
pub fn new( | ||
py: Python, | ||
cctx: Arc<CCtx<'static>>, | ||
writer: &PyAny, | ||
source_size: u64, | ||
write_size: usize, | ||
write_return_read: bool, | ||
closefd: bool, | ||
) -> Self { | ||
Self { | ||
cctx, | ||
writer: writer.into_py(py), | ||
source_size, | ||
write_size, | ||
write_return_read, | ||
closefd, | ||
entered: false, | ||
closing: false, | ||
closed: false, | ||
bytes_compressed: 0, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters