5 releases (3 breaking)
new 0.4.1 | Mar 17, 2025 |
---|---|
0.4.0 | Mar 17, 2025 |
0.3.0 | Jun 25, 2024 |
0.2.0 | Nov 26, 2023 |
0.1.0 | Nov 26, 2023 |
#336 in Development tools
13,997 downloads per month
Used in 8 crates
(via breezyshim)
14KB
281 lines
Rust compatible wrappers for file-like objects in Python
This crate provides implementations of the Write
, Seek
, Read
and AsRawFd
rust traits on top of file-like objects in PyO3.
Example
let o = pyo3::Python::with_gil(|py| {
let io = py.import("io")?;
io.call_method1("BytesIO", ("hello",))
})?;
let f = py3o_filelike::PyBinaryFile::from(o);
let mut buf = [0u8; 4];
f.read_exact(&mut buf)?;
assert_eq!(&buf, b"hell");
Dependencies
~2.5MB
~51K SLoC