Skip to content
Draft
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libipld"
version = "3.4.1"
version = "3.5.0"
edition = "2021"
license = "MIT"
description = "Python binding to the Rust IPLD library"
Expand All @@ -17,6 +17,7 @@ pyo3 = { version = "0.28.3", features = ["generate-import-lib", "anyhow"] }
python3-dll-a = "0.2.15"
anyhow = "1.0.102"
cid = "0.11.3"
ipld-core = "0.4"
cbor4ii = { version = "1.2.2" }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/car.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn decode_car<'py>(py: Python<'py>, data: &[u8]) -> PyResult<(Py<PyAny>, Bou
// `&[u8]` is itself an `io::Read`, so we hand it to `Cid::read_bytes`
// directly and recover the consumed length from the slice shrink.
let mut slice: &[u8] = cid_bytes_before;
let cid_result = ::cid::Cid::read_bytes(&mut slice);
let cid_result = ::ipld_core::cid::Cid::read_bytes(&mut slice);
let Ok(cid) = cid_result else {
return Err(value_error(
"Failed to read CID of block",
Expand Down
6 changes: 3 additions & 3 deletions src/cid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pub(crate) fn looks_like_cid(bytes: &[u8]) -> bool {
bytes.len() == 34 && bytes[0] == 0x12 && bytes[1] == 0x20
}

pub(crate) fn extract_cid(data: &Bound<PyAny>) -> PyResult<::cid::Cid> {
pub(crate) fn extract_cid(data: &Bound<PyAny>) -> PyResult<::ipld_core::cid::Cid> {
let cid = if let Ok(s) = data.cast::<PyString>() {
::cid::Cid::try_from(s.to_str()?)
::ipld_core::cid::Cid::try_from(s.to_str()?)
} else {
::cid::Cid::try_from(extract_bytes(data)?)
::ipld_core::cid::Cid::try_from(extract_bytes(data)?)
};

if let Ok(cid) = cid {
Expand Down
4 changes: 2 additions & 2 deletions src/cid/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use pyo3::types::*;

use crate::cid::extract_cid;

fn hash_to_pydict<'py>(py: Python<'py>, cid: &::cid::Cid) -> PyResult<Bound<'py, PyDict>> {
fn hash_to_pydict<'py>(py: Python<'py>, cid: &::ipld_core::cid::Cid) -> PyResult<Bound<'py, PyDict>> {
let hash = cid.hash();
let dict_obj = PyDict::new(py);

Expand All @@ -14,7 +14,7 @@ fn hash_to_pydict<'py>(py: Python<'py>, cid: &::cid::Cid) -> PyResult<Bound<'py,
Ok(dict_obj)
}

fn to_pydict<'py>(py: Python<'py>, cid: &::cid::Cid) -> PyResult<Bound<'py, PyDict>> {
fn to_pydict<'py>(py: Python<'py>, cid: &::ipld_core::cid::Cid) -> PyResult<Bound<'py, PyDict>> {
let dict_obj = PyDict::new(py);

dict_obj.set_item("version", cid.version() as u64)?;
Expand Down
2 changes: 1 addition & 1 deletion src/dag_cbor/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ where
}

let cid_without_prefix = &cid[1..];
if ::cid::Cid::try_from(cid_without_prefix).is_err() {
if ::ipld_core::cid::Cid::try_from(cid_without_prefix).is_err() {
return Err(anyhow!("Invalid CID"));
}

Expand Down
4 changes: 2 additions & 2 deletions src/dag_cbor/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ where
if tp == &raw mut ffi::PyBytes_Type {
let b = obj.cast_unchecked::<PyBytes>();
let bytes = b.as_bytes();
if looks_like_cid(bytes) && ::cid::Cid::try_from(bytes).is_ok() {
if looks_like_cid(bytes) && ::ipld_core::cid::Cid::try_from(bytes).is_ok() {
// by providing custom encoding we avoid extra allocation
types::Tag(42, PrefixedCidBytes(bytes)).encode(w)?;
} else {
Expand Down Expand Up @@ -187,7 +187,7 @@ where
Ok(())
} else if let Ok(b) = obj.cast::<PyBytes>() {
let bytes = b.as_bytes();
if looks_like_cid(bytes) && ::cid::Cid::try_from(bytes).is_ok() {
if looks_like_cid(bytes) && ::ipld_core::cid::Cid::try_from(bytes).is_ok() {
types::Tag(42, PrefixedCidBytes(bytes)).encode(w)?;
} else {
types::Bytes(bytes).encode(w)?;
Expand Down
2 changes: 1 addition & 1 deletion src/multibase/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::error::value_error;

#[pyfunction]
pub fn decode_multibase<'py>(py: Python<'py>, data: &str) -> PyResult<(char, Bound<'py, PyBytes>)> {
let base = ::cid::multibase::decode(data);
let base = ::ipld_core::cid::multibase::decode(data);
if let Ok((base, data)) = base {
Ok((base.code(), PyBytes::new(py, &data)))
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/multibase/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::error::value_error;
#[pyfunction]
pub fn encode_multibase(code: char, data: &Bound<PyAny>) -> PyResult<String> {
let data_bytes = extract_bytes(data)?;
let base = ::cid::multibase::Base::from_code(code);
let base = ::ipld_core::cid::multibase::Base::from_code(code);
if let Ok(base) = base {
Ok(::cid::multibase::encode(base, data_bytes))
Ok(::ipld_core::cid::multibase::encode(base, data_bytes))
} else {
Err(value_error(
"Failed to encode multibase",
Expand Down