Skip to content

Commit

Permalink
rust: implement iterator protocol for Zstd[De]CompressionWriter
Browse files Browse the repository at this point in the history
This should have been done in commit
1317207.
  • Loading branch information
indygreg committed Jan 17, 2022
1 parent c39f5b3 commit adff317
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rust-ext/src/compression_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
exceptions::{PyNotImplementedError, PyOSError, PyValueError},
prelude::*,
types::PyBytes,
PyIterProtocol,
},
std::sync::Arc,
};
Expand Down Expand Up @@ -304,3 +305,22 @@ impl ZstdCompressionWriter {
self.bytes_compressed
}
}

#[pyproto]
impl PyIterProtocol for ZstdCompressionWriter {
fn __iter__(slf: PyRef<Self>) -> PyResult<()> {
let py = slf.py();
let io = py.import("io")?;
let exc = io.getattr("UnsupportedOperation")?;

Err(PyErr::from_instance(exc))
}

fn __next__(slf: PyRef<Self>) -> PyResult<Option<()>> {
let py = slf.py();
let io = py.import("io")?;
let exc = io.getattr("UnsupportedOperation")?;

Err(PyErr::from_instance(exc))
}
}
20 changes: 20 additions & 0 deletions rust-ext/src/decompression_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
exceptions::{PyOSError, PyValueError},
prelude::*,
types::PyBytes,
PyIterProtocol,
},
std::sync::Arc,
};
Expand Down Expand Up @@ -276,3 +277,22 @@ impl ZstdDecompressionWriter {
}
}
}

#[pyproto]
impl PyIterProtocol for ZstdDecompressionWriter {
fn __iter__(slf: PyRef<Self>) -> PyResult<()> {
let py = slf.py();
let io = py.import("io")?;
let exc = io.getattr("UnsupportedOperation")?;

Err(PyErr::from_instance(exc))
}

fn __next__(slf: PyRef<Self>) -> PyResult<Option<()>> {
let py = slf.py();
let io = py.import("io")?;
let exc = io.getattr("UnsupportedOperation")?;

Err(PyErr::from_instance(exc))
}
}

0 comments on commit adff317

Please sign in to comment.