diff --git a/Cargo.toml b/Cargo.toml index 08ae5ee..a53450a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -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] diff --git a/src/car.rs b/src/car.rs index 410d1ee..4be0750 100644 --- a/src/car.rs +++ b/src/car.rs @@ -71,7 +71,7 @@ pub fn decode_car<'py>(py: Python<'py>, data: &[u8]) -> PyResult<(Py, 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", diff --git a/src/cid.rs b/src/cid.rs index 834d6db..5fa06c6 100644 --- a/src/cid.rs +++ b/src/cid.rs @@ -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) -> PyResult<::cid::Cid> { + pub(crate) fn extract_cid(data: &Bound) -> PyResult<::ipld_core::cid::Cid> { let cid = if let Ok(s) = data.cast::() { - ::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 { diff --git a/src/cid/de.rs b/src/cid/de.rs index f0e06ee..6e7136f 100644 --- a/src/cid/de.rs +++ b/src/cid/de.rs @@ -3,7 +3,7 @@ use pyo3::types::*; use crate::cid::extract_cid; -fn hash_to_pydict<'py>(py: Python<'py>, cid: &::cid::Cid) -> PyResult> { +fn hash_to_pydict<'py>(py: Python<'py>, cid: &::ipld_core::cid::Cid) -> PyResult> { let hash = cid.hash(); let dict_obj = PyDict::new(py); @@ -14,7 +14,7 @@ fn hash_to_pydict<'py>(py: Python<'py>, cid: &::cid::Cid) -> PyResult(py: Python<'py>, cid: &::cid::Cid) -> PyResult> { +fn to_pydict<'py>(py: Python<'py>, cid: &::ipld_core::cid::Cid) -> PyResult> { let dict_obj = PyDict::new(py); dict_obj.set_item("version", cid.version() as u64)?; diff --git a/src/dag_cbor/de.rs b/src/dag_cbor/de.rs index 5522ac7..ac8833f 100644 --- a/src/dag_cbor/de.rs +++ b/src/dag_cbor/de.rs @@ -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")); } diff --git a/src/dag_cbor/ser.rs b/src/dag_cbor/ser.rs index 280408d..506f3e9 100644 --- a/src/dag_cbor/ser.rs +++ b/src/dag_cbor/ser.rs @@ -133,7 +133,7 @@ where if tp == &raw mut ffi::PyBytes_Type { let b = obj.cast_unchecked::(); 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 { @@ -187,7 +187,7 @@ where Ok(()) } else if let Ok(b) = obj.cast::() { 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)?; diff --git a/src/multibase/de.rs b/src/multibase/de.rs index de78e1a..51bab1f 100644 --- a/src/multibase/de.rs +++ b/src/multibase/de.rs @@ -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 { diff --git a/src/multibase/ser.rs b/src/multibase/ser.rs index 9004eb2..30f9571 100644 --- a/src/multibase/ser.rs +++ b/src/multibase/ser.rs @@ -6,9 +6,9 @@ use crate::error::value_error; #[pyfunction] pub fn encode_multibase(code: char, data: &Bound) -> PyResult { 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",