Skip to content

Commit 9cdd5ae

Browse files
committed
refactor: upgrade to PyO3 to v0.29
1 parent 535de74 commit 9cdd5ae

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repository = "https://github.com/ApeWorX/blake2b-py"
88
description = "Blake2b hashing in Rust with Python bindings."
99

1010
[dependencies]
11-
pyo3 = { version = "~0.23", features = ["extension-module"] }
11+
pyo3 = { version = "~0.29", features = ["extension-module"] }
1212

1313
[dev-dependencies]
1414
hex = "~0.4"

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ fn checked_compress(
103103
/// out : bytes
104104
/// A vector of 64 bytes representing the blake2b hash of the input data.
105105
#[pyfunction]
106-
fn compress(
107-
py: Python,
106+
fn compress<'py>(
107+
py: Python<'py>,
108108
rounds: usize,
109109
starting_state: Vec<u64>,
110110
block: Vec<u64>,
111111
offset_counters: Vec<u64>,
112112
final_block_flag: bool,
113-
) -> PyResult<PyObject> {
113+
) -> PyResult<Bound<'py, PyBytes>> {
114114
let result = checked_compress(
115115
rounds,
116116
&starting_state,
@@ -121,7 +121,7 @@ fn compress(
121121

122122
match result {
123123
Err(msg) => Err(PyValueError::new_err(msg)),
124-
Ok(ok) => Ok(PyBytes::new(py, &ok).into()),
124+
Ok(ok) => Ok(PyBytes::new(py, &ok)),
125125
}
126126
}
127127

@@ -146,12 +146,12 @@ fn _decode_and_compress(input: Vec<u8>) -> Result<[u8; 64], String> {
146146
/// out : bytes
147147
/// A vector of 64 bytes representing the blake2b hash of the input data.
148148
#[pyfunction]
149-
fn decode_and_compress(py: Python, input: Vec<u8>) -> PyResult<PyObject> {
149+
fn decode_and_compress<'py>(py: Python<'py>, input: Vec<u8>) -> PyResult<Bound<'py, PyBytes>> {
150150
let result = _decode_and_compress(input);
151151

152152
match result {
153153
Err(msg) => Err(PyValueError::new_err(msg)),
154-
Ok(ok) => Ok(PyBytes::new(py, &ok).into()),
154+
Ok(ok) => Ok(PyBytes::new(py, &ok)),
155155
}
156156
}
157157

0 commit comments

Comments
 (0)