Skip to content

Commit

Permalink
Remove std feature, use core::error::Error, update docs
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Varlakov <[email protected]>
  • Loading branch information
survived committed Dec 4, 2024
1 parent c0053fb commit ba9ebaf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ generic-ec = { version = "0.4", default-features = false, features = ["curve-sta

[features]
default = []
std = []
# Adds support of secp256k1 curve to slip10 derivation
curve-secp256k1 = ["generic-ec/curve-secp256k1", "slip10"]
# Adds support of secp256r1 curve to slip10 derivation
Expand All @@ -37,7 +36,7 @@ curve-secp256r1 = ["generic-ec/curve-secp256r1", "slip10"]
curve-ed25519 = ["generic-ec/curve-ed25519", "edwards"]
# Enables Stark-specific derivation
curve-stark = ["generic-ec/curve-stark", "stark"]
all-curves = ["curve-secp256k1", "curve-secp256r1", "curve-ed25519"]
all-curves = ["curve-secp256k1", "curve-secp256r1", "curve-ed25519", "curve-stark"]
serde = ["dep:serde", "generic-ec/serde"]

# Enables Slip10 derivation
Expand Down
11 changes: 4 additions & 7 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ impl fmt::Display for InvalidLength {
}
}

#[cfg(feature = "std")]
impl std::error::Error for InvalidLength {}
impl core::error::Error for InvalidLength {}

/// Value was out of range
#[derive(Debug)]
Expand All @@ -25,8 +24,7 @@ impl fmt::Display for OutOfRange {
}
}

#[cfg(feature = "std")]
impl std::error::Error for OutOfRange {}
impl core::error::Error for OutOfRange {}

/// Error returned by parsing child index
#[derive(Debug)]
Expand All @@ -46,9 +44,8 @@ impl fmt::Display for ParseChildIndexError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for ParseChildIndexError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
impl core::error::Error for ParseChildIndexError {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
match self {
ParseChildIndexError::ParseInt(e) => Some(e),
ParseChildIndexError::IndexNotInRange(e) => Some(e),
Expand Down
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,19 @@
//! ```
//!
//! ### Features
//! * `std`: enables std library support (mainly, it just implements [`Error`](std::error::Error)
//! trait for the error types)
//! * `curve-secp256k1`, `curve-secp256r1`, `curve-ed25519` add curve implementation into the crate
//! [curves] module
//! * `curve-secp256k1`, `curve-secp256r1`, `curve-ed25519`, `curve-stark` add curve implementation
//! into the crate [curves] module
//! * `all-curves` adds all curves listed above
//! * `slip10`, `edwards`, `stark` add [`slip10`], [`edwards`], and [`stark`] HD derivations respectively
//! * `serde` adds `serde::{Serialize, Deserialize}` traits implementation to the types in the library
//!
//! ## Join us in Discord!
//! Feel free to reach out to us [in Discord](https://discordapp.com/channels/905194001349627914/1285268686147424388)!
//!
//! [slip10-spec]: https://github.com/satoshilabs/slips/blob/master/slip-0010.md
//! [bip32-spec]: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
#![cfg_attr(not(feature = "std"), no_std)]
#![no_std]
#![forbid(missing_docs, unsafe_code)]
#![cfg_attr(not(test), forbid(unused_crate_dependencies))]

Expand Down

0 comments on commit ba9ebaf

Please sign in to comment.