Skip to content
Closed
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
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ libipld-core = { version = "0.16.0", path = "core" }
libipld-json = { version = "0.16.0", path = "dag-json", optional = true }
libipld-macro = { version = "0.16.0", path = "macro" }
libipld-pb = { version = "0.16.0", path = "dag-pb", optional = true }
log = "0.4.14"
multihash = { version = "0.18.0", default-features = false, features = ["multihash-impl"] }
thiserror = "1.0.25"
multihash-codetable = "0.1.4"

[dev-dependencies]
multihash-codetable = { version = "0.1.4", features = ["blake3"] }
async-std = { version = "1.9.0", features = ["attributes"] }
criterion = "0.3.4"
proptest = "1.0.0"
Expand Down
6 changes: 3 additions & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ arb = ["quickcheck", "cid/arb"]

[dependencies]
anyhow = { version = "1.0.40", default-features = false }
cid = { version = "0.10.0", default-features = false, features = ["alloc"] }
cid = { version = "0.11.1", default-features = false, features = ["alloc"] }
core2 = { version = "0.4", default-features = false, features = ["alloc"] }
multihash = { version = "0.18.0", default-features = false, features = ["alloc"] }
multihash = { version = "0.19.3", default-features = false, features = ["alloc"] }

multibase = { version = "0.9.1", default-features = false, optional = true }
serde = { version = "1.0.132", default-features = false, features = ["alloc"], optional = true }
thiserror = {version = "1.0.25", optional = true }
quickcheck = { version = "1.0", optional = true }

[dev-dependencies]
multihash = { version = "0.18.0", default-features = false, features = ["multihash-impl", "blake3"] }
multihash-codetable = { version = "0.1.4", features = ["blake3"] }
serde_test = "1.0.132"
serde_bytes = "0.11.5"
serde_json = "1.0.79"
6 changes: 3 additions & 3 deletions core/src/ipld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ pub enum IpldIndex<'a> {
MapRef(&'a str),
}

impl<'a> From<usize> for IpldIndex<'a> {
impl From<usize> for IpldIndex<'_> {
fn from(index: usize) -> Self {
Self::List(index)
}
}

impl<'a> From<String> for IpldIndex<'a> {
impl From<String> for IpldIndex<'_> {
fn from(key: String) -> Self {
Self::Map(key)
}
Expand Down Expand Up @@ -195,7 +195,7 @@ impl<'a> Iterator for IpldIter<'a> {
mod tests {
use super::*;
use crate::cid::Cid;
use crate::multihash::{Code, MultihashDigest};
use multihash_codetable::{Code, MultihashDigest};

#[test]
fn test_ipld_bool_from() {
Expand Down
44 changes: 22 additions & 22 deletions core/src/serde/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ impl serde::Serializer for Serializer {
}

#[inline]
fn serialize_newtype_struct<T: ?Sized>(
fn serialize_newtype_struct<T>(
self,
name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
let ipld = value.serialize(self);
if name == CID_SERDE_PRIVATE_IDENTIFIER {
Expand All @@ -227,15 +227,15 @@ impl serde::Serializer for Serializer {
ipld
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
let values = BTreeMap::from([(variant.to_owned(), value.serialize(self)?)]);
Ok(Self::Ok::Map(values))
Expand All @@ -247,9 +247,9 @@ impl serde::Serializer for Serializer {
}

#[inline]
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
value.serialize(self)
}
Expand Down Expand Up @@ -342,9 +342,9 @@ impl ser::SerializeSeq for SerializeVec {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
self.vec.push(value.serialize(Serializer)?);
Ok(())
Expand All @@ -359,9 +359,9 @@ impl ser::SerializeTuple for SerializeVec {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
ser::SerializeSeq::serialize_element(self, value)
}
Expand All @@ -375,9 +375,9 @@ impl ser::SerializeTupleStruct for SerializeVec {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
ser::SerializeSeq::serialize_element(self, value)
}
Expand All @@ -391,9 +391,9 @@ impl ser::SerializeTupleVariant for SerializeTupleVariant {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
self.vec.push(value.serialize(Serializer)?);
Ok(())
Expand All @@ -409,9 +409,9 @@ impl ser::SerializeMap for SerializeMap {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
match key.serialize(Serializer)? {
Ipld::String(string_key) => {
Expand All @@ -422,9 +422,9 @@ impl ser::SerializeMap for SerializeMap {
}
}

fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
let key = self.next_key.take();
// Panic because this indicates a bug in the program rather than an
Expand All @@ -443,13 +443,13 @@ impl ser::SerializeStruct for SerializeMap {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(
fn serialize_field<T>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
serde::ser::SerializeMap::serialize_key(self, key)?;
serde::ser::SerializeMap::serialize_value(self, value)
Expand All @@ -464,13 +464,13 @@ impl ser::SerializeStructVariant for SerializeStructVariant {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(
fn serialize_field<T>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
self.map
.insert(key.to_string(), value.serialize(Serializer)?);
Expand Down
2 changes: 2 additions & 0 deletions dag-cbor-derive/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod kw {
custom_keyword!(default);
}

#[allow(dead_code)]
#[derive(Debug)]
pub struct Attrs<A> {
pub paren: syn::token::Paren,
Expand All @@ -25,6 +26,7 @@ impl<A: Parse> Parse for Attrs<A> {
}
}

#[allow(dead_code)]
#[derive(Debug)]
pub struct Attr<K, V> {
pub key: K,
Expand Down
2 changes: 1 addition & 1 deletion dag-cbor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ thiserror = "1.0.25"
[dev-dependencies]
hex = "0.4.3"
libipld-macro = { path = "../macro" }
multihash = "0.17.0"
multihash-codetable = { version = "0.1.4", features = ["blake3"] }
quickcheck = "1.0.3"
serde_cbor = { version = "0.11.1", features = ["tags"] }
20 changes: 10 additions & 10 deletions dag-cbor/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ pub fn write_null<W: Write>(w: &mut W) -> Result<()> {
pub fn write_u8<W: Write>(w: &mut W, major: MajorKind, value: u8) -> Result<()> {
let major = major as u8;
if value <= 0x17 {
let buf = [major << 5 | value];
let buf = [(major << 5) | value];
w.write_all(&buf)?;
} else {
let buf = [major << 5 | 24, value];
let buf = [(major << 5) | 24, value];
w.write_all(&buf)?;
}
Ok(())
}

/// Writes a u16 to a cbor encoded byte stream.
pub fn write_u16<W: Write>(w: &mut W, major: MajorKind, value: u16) -> Result<()> {
if value <= u16::from(u8::max_value()) {
if value <= u16::from(u8::MAX) {
write_u8(w, major, value as u8)?;
} else {
let mut buf = [(major as u8) << 5 | 25, 0, 0];
let mut buf = [((major as u8) << 5) | 25, 0, 0];
BigEndian::write_u16(&mut buf[1..], value);
w.write_all(&buf)?;
}
Expand All @@ -50,10 +50,10 @@ pub fn write_u16<W: Write>(w: &mut W, major: MajorKind, value: u16) -> Result<()

/// Writes a u32 to a cbor encoded byte stream.
pub fn write_u32<W: Write>(w: &mut W, major: MajorKind, value: u32) -> Result<()> {
if value <= u32::from(u16::max_value()) {
if value <= u32::from(u16::MAX) {
write_u16(w, major, value as u16)?;
} else {
let mut buf = [(major as u8) << 5 | 26, 0, 0, 0, 0];
let mut buf = [((major as u8) << 5) | 26, 0, 0, 0, 0];
BigEndian::write_u32(&mut buf[1..], value);
w.write_all(&buf)?;
}
Expand All @@ -62,10 +62,10 @@ pub fn write_u32<W: Write>(w: &mut W, major: MajorKind, value: u32) -> Result<()

/// Writes a u64 to a cbor encoded byte stream.
pub fn write_u64<W: Write>(w: &mut W, major: MajorKind, value: u64) -> Result<()> {
if value <= u64::from(u32::max_value()) {
if value <= u64::from(u32::MAX) {
write_u32(w, major, value as u32)?;
} else {
let mut buf = [(major as u8) << 5 | 27, 0, 0, 0, 0, 0, 0, 0, 0];
let mut buf = [((major as u8) << 5) | 27, 0, 0, 0, 0, 0, 0, 0, 0];
BigEndian::write_u64(&mut buf[1..], value);
w.write_all(&buf)?;
}
Expand Down Expand Up @@ -224,12 +224,12 @@ impl Encode<DagCbor> for String {
impl Encode<DagCbor> for i128 {
fn encode<W: Write>(&self, _: DagCbor, w: &mut W) -> Result<()> {
if *self < 0 {
if -(*self + 1) > u64::max_value() as i128 {
if -(*self + 1) > u64::MAX as i128 {
return Err(NumberOutOfRange::new::<i128>().into());
}
write_u64(w, MajorKind::NegativeInt, -(*self + 1) as u64)?;
} else {
if *self > u64::max_value() as i128 {
if *self > u64::MAX as i128 {
return Err(NumberOutOfRange::new::<i128>().into());
}
write_u64(w, MajorKind::UnsignedInt, *self as u64)?;
Expand Down
2 changes: 1 addition & 1 deletion dag-cbor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod tests {
use libipld_core::cid::Cid;
use libipld_core::codec::assert_roundtrip;
use libipld_core::ipld::Ipld;
use libipld_core::multihash::{Code, MultihashDigest};
use multihash_codetable::{Code, MultihashDigest};
use libipld_macro::ipld;
use std::collections::HashSet;

Expand Down
2 changes: 1 addition & 1 deletion dag-json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ repository = "https://github.com/ipfs-rust/rust-ipld"

[dependencies]
libipld-core = { version = "0.16.0", path = "../core" }
multihash = "0.18.0"
serde_json = { version = "1.0.64", features = ["float_roundtrip"] }
serde = { version = "1.0.126", features = ["derive"] }
multihash-codetable = { version = "0.1.4", features = ["blake3"] }
2 changes: 1 addition & 1 deletion dag-json/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn deserialize<'de, D: de::Deserializer<'de>>(deserializer: D) -> Result<Ipld, D
// Needed for `collect_seq` and `collect_map` in Seserializer
struct Wrapper<'a>(&'a Ipld);

impl<'a> Serialize for Wrapper<'a> {
impl Serialize for Wrapper<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: ser::Serializer,
Expand Down
2 changes: 1 addition & 1 deletion dag-json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl References<DagJsonCodec> for Ipld {
mod tests {
use super::*;
use libipld_core::cid::Cid;
use libipld_core::multihash::{Code, MultihashDigest};
use multihash_codetable::{Code, MultihashDigest};
use std::collections::BTreeMap;

#[test]
Expand Down
3 changes: 1 addition & 2 deletions dag-pb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ repository = "https://github.com/ipfs-rust/rust-ipld"

[dependencies]
libipld-core = { version = "0.16.0", path = "../core" }
thiserror = "1.0.25"
quick-protobuf = "0.8.1"
bytes = "1.3.0"

[dev-dependencies]
libipld-macro = { path = "../macro" }
libipld = { path = "../" }
multihash = "0.18.0"
multihash-codetable = { version = "0.1.4", features = ["blake3"] }
hex = "0.4.3"
2 changes: 1 addition & 1 deletion dag-pb/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl MessageWrite for PbLink {
size += 1 + sizeof_len(l);

if let Some(ref name) = self.name {
size += 1 + sizeof_len(name.as_bytes().len());
size += 1 + sizeof_len(name.len());
}

if let Some(tsize) = self.size {
Expand Down
2 changes: 1 addition & 1 deletion dag-pb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl References<DagPbCodec> for Ipld {
mod tests {
use super::*;
use libipld_core::cid::Cid;
use libipld_core::multihash::{Code, MultihashDigest};
use multihash_codetable::{Code, MultihashDigest};
use std::collections::BTreeMap;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ repository = "https://github.com/ipfs-rust/rust-ipld"
libipld-core = { version = "0.16.0", path = "../core" }

[dev-dependencies]
multihash = { version = "0.18.0", features = ["blake3"] }
multihash-codetable = { version = "0.1.4", features = ["blake3"] }
2 changes: 1 addition & 1 deletion macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ macro_rules! ipld_unexpected {
mod tests {
use super::*;
use libipld_core::cid::Cid;
use libipld_core::multihash::{Code, MultihashDigest};
use multihash_codetable::{Code, MultihashDigest};

#[test]
fn test_macro() {
Expand Down
Loading
Loading