Skip to content

Commit

Permalink
feat: Make Error trait available in no_std mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sorairolake committed Oct 14, 2024
1 parent bf999f2 commit 911e138
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- aarch64-apple-darwin
- x86_64-pc-windows-msvc
toolchain:
- 1.74.0 # MSRV
- 1.81.0 # MSRV
- stable
include:
- target: x86_64-unknown-linux-gnu
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
strategy:
matrix:
toolchain:
- 1.74.0 # MSRV
- 1.81.0 # MSRV
- stable
steps:
- name: Checkout code
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = ["crates/*"]
[workspace.package]
authors = ["Shun Sakai <[email protected]>"]
edition = "2021"
rust-version = "1.74.0"
rust-version = "1.81.0"
homepage = "https://sorairolake.github.io/scryptenc-rs/"
repository = "https://github.com/sorairolake/scryptenc-rs"

Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

msrv = "1.74.0"
msrv = "1.81.0"
2 changes: 1 addition & 1 deletion crates/cli/BUILD.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
== Prerequisites

.To build *rscrypt*, you will need the following dependencies
* https://doc.rust-lang.org/stable/cargo/[Cargo] (v1.74.0 or later)
* https://doc.rust-lang.org/stable/cargo/[Cargo] (v1.81.0 or later)

.To build man pages, you will need the following additional dependencies
* https://asciidoctor.org/[Asciidoctor]
Expand Down
6 changes: 6 additions & 0 deletions crates/cli/CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ All notable changes to this project will be documented in this file.
The format is based on https://keepachangelog.com/[Keep a Changelog], and this
project adheres to https://semver.org/[Semantic Versioning].

== {compare-url}/scryptenc-cli-v0.7.13\...HEAD[Unreleased]

=== Changed

* Bump MSRV to 1.81.0 ({pull-request-url}/432[#432])

== {compare-url}/scryptenc-cli-v0.7.12\...scryptenc-cli-v0.7.13[0.7.13] - 2024-08-04

=== Changed
Expand Down
1 change: 0 additions & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ clap_complete_nushell = "4.5.3"
dialoguer.workspace = true
fraction = { version = "0.15.3", default-features = false }
humantime = "2.1.0"
once_cell = "1.20.2"
scryptenc = { version = "0.9.8", path = "../scryptenc" }
serde = { version = "1.0.210", features = ["derive"], optional = true }
serde_json = { version = "1.0.128", optional = true }
Expand Down
10 changes: 6 additions & 4 deletions crates/cli/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

use std::time::{Duration, Instant};
use std::{
sync::LazyLock,
time::{Duration, Instant},
};

use anyhow::Context;
use byte_unit::UnitType;
use fraction::{Fraction, GenericFraction, ToPrimitive};
use once_cell::sync::Lazy;
use scryptenc::scrypt;
use sysinfo::System;
use thiserror::Error;
Expand All @@ -18,8 +20,8 @@ type U128Fraction = GenericFraction<u128>;

const SECOND: Duration = Duration::from_secs(1);

static SYSTEM: Lazy<System> = Lazy::new(System::new_all);
static OPERATIONS_PER_SECOND: Lazy<u64> = Lazy::new(get_scrypt_performance);
static SYSTEM: LazyLock<System> = LazyLock::new(System::new_all);
static OPERATIONS_PER_SECOND: LazyLock<u64> = LazyLock::new(get_scrypt_performance);

/// The error type for this module.
#[derive(Debug, Error)]
Expand Down
7 changes: 7 additions & 0 deletions crates/scryptenc/CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ All notable changes to this project will be documented in this file.
The format is based on https://keepachangelog.com/[Keep a Changelog], and this
project adheres to https://semver.org/[Semantic Versioning].

== {compare-url}/scryptenc-v0.9.8\...HEAD[Unreleased]

=== Changed

* Make `Error` trait available in `no_std` mode ({pull-request-url}/432[#432])
* Bump MSRV to 1.81.0 ({pull-request-url}/432[#432])

== {compare-url}/scryptenc-v0.9.7\...scryptenc-v0.9.8[0.9.8] - 2024-07-31

=== Added
Expand Down
2 changes: 1 addition & 1 deletion crates/scryptenc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ See the [documentation][docs-url] for more details.

## Minimum supported Rust version

The minimum supported Rust version (MSRV) of this library is v1.74.0.
The minimum supported Rust version (MSRV) of this library is v1.81.0.

## Source code

Expand Down
10 changes: 4 additions & 6 deletions crates/scryptenc/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! Error types for this crate.

use core::{fmt, result};
use core::{error, fmt, result};

use hmac::digest::MacError;
use scrypt::errors::InvalidParams;
Expand Down Expand Up @@ -50,10 +50,9 @@ impl fmt::Display for Error {
}
}

#[cfg(feature = "std")]
impl std::error::Error for Error {
impl error::Error for Error {
#[inline]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Self::InvalidParams(err) => Some(err),
Self::InvalidHeaderMac(err) | Self::InvalidMac(err) => Some(err),
Expand Down Expand Up @@ -323,10 +322,9 @@ mod tests {
assert_eq!(format!("{}", Error::InvalidMac(MacError)), "invalid MAC");
}

#[cfg(feature = "std")]
#[test]
fn source() {
use std::error::Error as _;
use error::Error as _;

assert!(Error::InvalidLength.source().is_none());
assert!(Error::InvalidMagicNumber.source().is_none());
Expand Down
2 changes: 0 additions & 2 deletions crates/scryptenc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@
#[cfg(feature = "alloc")]
#[macro_use]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;

mod decrypt;
mod encrypt;
Expand Down
6 changes: 6 additions & 0 deletions crates/wasm/CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ All notable changes to this project will be documented in this file.
The format is based on https://keepachangelog.com/[Keep a Changelog], and this
project adheres to https://semver.org/[Semantic Versioning].

== {compare-url}/scryptenc-wasm-v0.2.3\...HEAD[Unreleased]

=== Changed

* Bump MSRV to 1.81.0 ({pull-request-url}/432[#432])

== {compare-url}/scryptenc-wasm-v0.2.2\...scryptenc-wasm-v0.2.3[0.2.3] - 2024-02-28

=== Changed
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ See the [documentation][docs-url] for more details.

## Minimum supported Rust version

The minimum supported Rust version (MSRV) of this library is v1.74.0.
The minimum supported Rust version (MSRV) of this library is v1.81.0.

## Source code

Expand Down

0 comments on commit 911e138

Please sign in to comment.