Skip to content

Commit

Permalink
fix: introduce codec feature flag
Browse files Browse the repository at this point in the history
Implementing the `Codec` trait needs at least Rust version 1.75. This commit
introduces a feature flag, so that lower versions of Rust can be supported,
in case the `Codec` trait implementation is not needed.
  • Loading branch information
vmx committed Mar 26, 2024
1 parent feb21ee commit 2536b54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ serde_bytes = { version = "0.11.9", default-features = false, features = ["alloc
serde-transcode = "1.1.1"

[features]
default = ["std"]
default = ["codec", "std"]
std = ["cbor4ii/use_std", "ipld-core/std", "serde/std", "serde_bytes/std"]
# Enable the `Codec` trait implementation. It's a separate feature as it needs Rust >= 1.75.
codec = ["ipld-core/codec"]
# Prevent deserializing CIDs as bytes as much as possible.
no-cid-as-bytes = []

[patch.crates-io]
ipld-core = { git = "https://github.com/ipld/rust-ipld-core", branch = "codec-feature-flag" }
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ extern crate alloc;
mod cbor4ii_nonpub;
// The `Codec` implementation is only available if the `no-cid-as-bytes` feature is disabled, due
// to the links being extracted with a Serde based approach.
#[cfg(all(feature = "std", not(feature = "no-cid-as-bytes")))]
#[cfg(all(feature = "std", not(feature = "no-cid-as-bytes"), feature = "codec"))]
pub mod codec;
pub mod de;
pub mod error;
Expand Down

0 comments on commit 2536b54

Please sign in to comment.