From ba9ebafae620ce046ef6116a3c05040cc544cb85 Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Wed, 4 Dec 2024 13:27:39 +0100 Subject: [PATCH] Remove std feature, use core::error::Error, update docs Signed-off-by: Denis Varlakov --- Cargo.toml | 3 +-- src/errors.rs | 11 ++++------- src/lib.rs | 11 ++++++----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 71bc57b..47acb77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 @@ -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 diff --git a/src/errors.rs b/src/errors.rs index 4c003e3..595e655 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -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)] @@ -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)] @@ -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), diff --git a/src/lib.rs b/src/lib.rs index 4178091..c666271 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,10 +54,11 @@ //! ``` //! //! ### 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)! @@ -65,7 +66,7 @@ //! [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))]