equal
deleted
inserted
replaced
30 node_from_py_bytes(py, as_py_bytes) |
30 node_from_py_bytes(py, as_py_bytes) |
31 } |
31 } |
32 |
32 |
33 /// Clone incoming Python bytes given as `PyBytes` as a `Node`, |
33 /// Clone incoming Python bytes given as `PyBytes` as a `Node`, |
34 /// doing the necessary checks. |
34 /// doing the necessary checks. |
35 pub fn node_from_py_bytes<'a>( |
35 pub fn node_from_py_bytes(py: Python, bytes: &PyBytes) -> PyResult<Node> { |
36 py: Python, |
|
37 bytes: &'a PyBytes, |
|
38 ) -> PyResult<Node> { |
|
39 <NodeData>::try_from(bytes.data(py)) |
36 <NodeData>::try_from(bytes.data(py)) |
40 .map_err(|_| { |
37 .map_err(|_| { |
41 PyErr::new::<ValueError, _>( |
38 PyErr::new::<ValueError, _>( |
42 py, |
39 py, |
43 format!("{}-byte hash required", NODE_BYTES_LENGTH), |
40 format!("{}-byte hash required", NODE_BYTES_LENGTH), |
44 ) |
41 ) |
45 }) |
42 }) |
46 .map(|n| n.into()) |
43 .map(Into::into) |
47 } |
44 } |