Skip to content

Commit bc0c9fd

Browse files
committed
make the stream types implement Send and Sync
1 parent 1e14851 commit bc0c9fd

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

zlib-rs/src/deflate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pub struct DeflateStream<'a> {
5050
pub(crate) reserved: crate::c_api::uLong,
5151
}
5252

53+
unsafe impl Sync for DeflateStream<'_> {}
54+
unsafe impl Send for DeflateStream<'_> {}
55+
5356
impl<'a> DeflateStream<'a> {
5457
// z_stream and DeflateStream must have the same layout. Do our best to check if this is true.
5558
// (imperfect check, but should catch most mistakes.)

zlib-rs/src/inflate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ pub struct InflateStream<'a> {
5050
pub(crate) reserved: crate::c_api::uLong,
5151
}
5252

53+
unsafe impl Sync for InflateStream<'_> {}
54+
unsafe impl Send for InflateStream<'_> {}
55+
5356
#[cfg(feature = "__internal-test")]
5457
#[doc(hidden)]
5558
pub const INFLATE_STATE_SIZE: usize = core::mem::size_of::<crate::inflate::State>();

zlib-rs/src/stable.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ impl InflateError {
6767
/// The state that is used to decompress an input.
6868
pub struct Inflate(crate::inflate::InflateStream<'static>);
6969

70-
// SAFETY: the stream contains raw pointers, but the `Deflate` API enforces
71-
// the correct aliasing and mutability constraints.
72-
unsafe impl Sync for Inflate {}
73-
unsafe impl Send for Inflate {}
74-
7570
impl Inflate {
7671
/// The amount of bytes consumed from the input so far.
7772
pub fn total_in(&self) -> u64 {
@@ -195,11 +190,6 @@ impl From<ReturnCode> for Result<Status, DeflateError> {
195190
/// The state that is used to compress an input.
196191
pub struct Deflate(crate::deflate::DeflateStream<'static>);
197192

198-
// SAFETY: the stream contains raw pointers, but the `Deflate` API enforces
199-
// the correct aliasing and mutability constraints.
200-
unsafe impl Sync for Deflate {}
201-
unsafe impl Send for Deflate {}
202-
203193
impl Deflate {
204194
/// The number of bytes that were read from the input.
205195
pub fn total_in(&self) -> u64 {

0 commit comments

Comments
 (0)