Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use workspace.dependencies #199

Closed
wants to merge 2 commits into from
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
79 changes: 60 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
[package]
name = "libipld"
version = "0.16.0"
authors = ["David Craven <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
description = "library for dealing with ipld"
repository = "https://github.com/ipld/libipld"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

[package.metadata.release]
consolidate-commits = true
shared-version = true

[dependencies]
fnv = "1.0.7"
libipld-cbor = { version = "0.16.0", path = "dag-cbor", optional = true }
libipld-cbor-derive = { version = "0.16.0", path = "dag-cbor-derive", optional = true }
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"
libipld-cbor = { workspace = true, optional = true }
libipld-cbor-derive = { workspace = true, optional = true }
libipld-core = { workspace = true }
libipld-json = { workspace = true, optional = true }
libipld-macro = { workspace = true }
libipld-pb = { workspace = true, optional = true }

multihash = { workspace = true, features = ["multihash-impl"] }
thiserror = { workspace = true }

[dev-dependencies]
async-std = { version = "1.9.0", features = ["attributes"] }
criterion = "0.3.4"
proptest = "1.0.0"
model = "0.1.2"
ahash = { workspace = true }
criterion = { workspace = true }
multihash = { workspace = true, features = ["blake3"] }

[features]
default = ["dag-cbor", "dag-json", "dag-pb", "derive"]
Expand All @@ -48,6 +46,49 @@ members = [
"macro",
"dag-cbor-derive/examples/renamed-package",
]
resolver = "2"

[workspace.package]
version = "0.16.0"
authors = ["David Craven <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/ipld/libipld"

[workspace.dependencies]
libipld = { path = "." }
libipld-cbor = { path = "dag-cbor" }
libipld-cbor-derive = { path = "dag-cbor-derive" }
libipld-core = { path = "core" }
libipld-json = { path = "dag-json" }
libipld-macro = { path = "macro" }
libipld-pb = { path = "dag-pb" }

# External dependencies
ahash = "0.8"
anyhow = { version = "1", default-features = false }
byteorder = "1"
bytes = "1"
cid = { version = "0.10", default-features = false, features = ["alloc"] }
core2 = { version = "0.4", default-features = false, features = ["alloc"] }
criterion = "0.5"
hex = "0.4"
multibase = { version = "0.9", default-features = false }
multihash = { version = "0.18", default-features = false, features = ["alloc"] }
proc-macro-crate = "1"
proc-macro2 = "1"
quick-protobuf = "0.8"
quickcheck = "1"
quote = "1"
serde = { version = "1", default-features = false, features = ["alloc"] }
serde_bytes = "0.11"
serde_cbor = "0.11"
serde_json = "1"
serde_test = "1"
syn = "1"
synstructure = "0.12"
thiserror = "2"
trybuild = "1"

[profile.release]
debug = true
Expand Down
39 changes: 19 additions & 20 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
[package]
name = "libipld-core"
version = "0.16.0"
authors = ["David Craven <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Base traits and definitions used by ipld codecs."
repository = "https://github.com/ipfs-rust/rust-ipld"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

[features]
default = ["std"]
std = ["anyhow/std", "cid/std", "multibase/std", "multihash/std", "thiserror"]
serde-codec = ["cid/serde-codec", "serde"]
arb = ["quickcheck", "cid/arb"]
serde-codec = ["cid/serde-codec", "dep:serde"]
arb = ["dep:quickcheck", "cid/arb"]

[dependencies]
anyhow = { version = "1.0.40", default-features = false }
cid = { version = "0.10.0", default-features = false, features = ["alloc"] }
core2 = { version = "0.4", default-features = false, features = ["alloc"] }
multihash = { version = "0.18.0", 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 }
anyhow = { workspace = true }
cid = { workspace = true }
core2 = { workspace = true }
multibase = { workspace = true }
multihash = { workspace = true }
quickcheck = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
thiserror = { workspace = true, optional = true }

[dev-dependencies]
multihash = { version = "0.18.0", default-features = false, features = ["multihash-impl", "blake3"] }
serde_test = "1.0.132"
serde_bytes = "0.11.5"
serde_json = "1.0.79"
multihash = { workspace = true, features = ["multihash-impl", "blake3"] }
serde_bytes = { workspace = true }
serde_json = { workspace = true }
serde_test = { workspace = true }
81 changes: 33 additions & 48 deletions core/src/serde/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,11 @@ impl serde::Serializer for Serializer {
}

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

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

#[inline]
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: ser::Serialize,
{
fn serialize_some<T: ser::Serialize + ?Sized>(
self,
value: &T,
) -> Result<Self::Ok, Self::Error> {
value.serialize(self)
}

Expand Down Expand Up @@ -342,10 +336,10 @@ impl ser::SerializeSeq for SerializeVec {
type Ok = Ipld;
type Error = SerdeError;

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

fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
{
fn serialize_element<T: ser::Serialize + ?Sized>(
&mut self,
value: &T,
) -> Result<(), Self::Error> {
ser::SerializeSeq::serialize_element(self, value)
}

Expand All @@ -375,10 +369,10 @@ impl ser::SerializeTupleStruct for SerializeVec {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
{
fn serialize_field<T: ser::Serialize + ?Sized>(
&mut self,
value: &T,
) -> Result<(), Self::Error> {
ser::SerializeSeq::serialize_element(self, value)
}

Expand All @@ -391,10 +385,10 @@ impl ser::SerializeTupleVariant for SerializeTupleVariant {
type Ok = Ipld;
type Error = SerdeError;

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

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

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

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

fn serialize_field<T: ?Sized>(
fn serialize_field<T: ser::Serialize + ?Sized>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: ser::Serialize,
{
) -> Result<(), Self::Error> {
self.map
.insert(key.to_string(), value.serialize(Serializer)?);
Ok(())
Expand Down
24 changes: 12 additions & 12 deletions dag-cbor-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[package]
name = "libipld-cbor-derive"
version = "0.16.0"
authors = ["David Craven <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
description = "ipld cbor codec proc macro"
repository = "https://github.com/ipfs-rust/rust-ipld"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

[lib]
proc-macro = true

[dependencies]
proc-macro-crate = "1.1.0"
proc-macro2 = "1.0.27"
quote = "1.0.9"
syn = "1.0.72"
synstructure = "0.12.4"
proc-macro-crate = { workspace = true }
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true }
synstructure = { workspace = true }

[dev-dependencies]
libipld = { path = ".." }
trybuild = "1.0.42"
libipld = { workspace = true }
trybuild = { workspace = true }
2 changes: 2 additions & 0 deletions dag-cbor-derive/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dependency_on_unit_never_type_fallback)]

use libipld::cbor::DagCborCodec;
use libipld::codec::assert_roundtrip;
use libipld::{ipld, DagCbor, Ipld};
Expand Down
2 changes: 2 additions & 0 deletions dag-cbor-derive/examples/name_attr.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dependency_on_unit_never_type_fallback)]

use libipld::cbor::DagCborCodec;
use libipld::codec::{Decode, Encode};
use libipld::ipld::Ipld;
Expand Down
2 changes: 1 addition & 1 deletion dag-cbor-derive/examples/renamed-package/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ publish = false
release = false

[dependencies]
ipld = { path = "../../../", package = "libipld"}
ipld = { path = "../../../", package = "libipld" }
2 changes: 2 additions & 0 deletions dag-cbor-derive/examples/renamed-package/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dependency_on_unit_never_type_fallback)]

//! The purpose of this example is to test whether the derive compiles if the libipld package was
//! renamed in the `Cargo.toml` file.
use ipld::DagCbor;
Expand Down
2 changes: 2 additions & 0 deletions dag-cbor-derive/examples/repr_attr.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dependency_on_unit_never_type_fallback)]

use libipld::cbor::DagCborCodec;
use libipld::codec::assert_roundtrip;
use libipld::{ipld, DagCbor};
Expand Down
2 changes: 2 additions & 0 deletions dag-cbor-derive/src/attr.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code)]

use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;

Expand Down
Loading