Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyo3-bytes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyo3-bytes"
version = "0.4.0"
version = "0.5.0"
authors = [
"Kyle Barron <[email protected]>",
"jesse rubin <[email protected]>",
Expand All @@ -17,7 +17,7 @@ rust-version = "1.75"
[dependencies]
# https://github.com/tokio-rs/bytes/releases/tag/v1.10.1
bytes = "1.10.1"
pyo3 = "0.26"
pyo3 = "0.27"

[lib]
crate-type = ["rlib"]
1 change: 1 addition & 0 deletions pyo3-bytes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ an idea, create an issue to discuss.
| 0.2.x | 0.24 |
| 0.3.x | 0.25 |
| 0.4.x | 0.26 |
| 0.5.x | 0.27 |
16 changes: 10 additions & 6 deletions pyo3-bytes/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,11 @@ impl PyBytes {
}
}

impl<'py> FromPyObject<'py> for PyBytes {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
let buffer = ob.extract::<PyBytesWrapper>()?;
impl<'py> FromPyObject<'_, 'py> for PyBytes {
type Error = PyErr;

fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result<Self, Self::Error> {
let buffer = obj.extract::<PyBytesWrapper>()?;
let bytes = Bytes::from_owner(buffer);
Ok(Self(bytes))
}
Expand Down Expand Up @@ -452,9 +454,11 @@ fn validate_buffer(buf: &PyBuffer<u8>) -> PyResult<()> {
Ok(())
}

impl<'py> FromPyObject<'py> for PyBytesWrapper {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
let buffer = ob.extract::<PyBuffer<u8>>()?;
impl<'py> FromPyObject<'_, 'py> for PyBytesWrapper {
type Error = PyErr;

fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result<Self, Self::Error> {
let buffer = obj.extract::<PyBuffer<u8>>()?;
validate_buffer(&buffer)?;
Ok(Self(buffer))
}
Expand Down
Loading