Skip to content

Commit 21c3e78

Browse files
committed
chore: displaydoc
1 parent 38be991 commit 21c3e78

File tree

7 files changed

+22
-36
lines changed

7 files changed

+22
-36
lines changed

rust/catalyst-types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ name = "catalyst_types"
1818
[dependencies]
1919
blake2b_simd = "1.0.2"
2020
coset = "0.3.8"
21+
displaydoc = "0.2.5"
2122
ed25519-dalek = "2.1.1"
2223
fluent-uri = "0.3.2"
2324
hex = "0.4.3"

rust/catalyst-types/src/conversion.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
//! Conversion functions
22
3+
use displaydoc::Display;
34
use thiserror::Error;
45

56
/// Errors that can occur when converting bytes to an Ed25519 verifying key.
6-
#[derive(Debug, Error)]
7+
#[derive(Display, Debug, Error)]
78
pub enum VKeyFromBytesError {
8-
/// Indicates the provided byte slice has an invalid length.
9-
#[error("Invalid byte length: expected {expected} bytes, got {actual}")]
9+
/// Invalid byte length: expected {expected} bytes, got {actual}
1010
InvalidLength {
1111
/// The expected number of bytes (must be 32).
1212
expected: usize,
1313
/// The actual number of bytes in the provided input.
1414
actual: usize,
1515
},
16-
/// Indicates that the bytes could not be parsed into an Ed25519 public key.
17-
#[error("Failed to parse Ed25519 public key: {source}")]
16+
/// Failed to parse Ed25519 public key: {source}
1817
ParseError {
1918
/// The underlying error from `ed25519_dalek`.
2019
#[from]

rust/catalyst-types/src/hashes.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::{fmt, str::FromStr};
44

55
use blake2b_simd::Params;
6+
use displaydoc::Display;
67
use pallas_crypto::hash::Hash;
78
use thiserror::Error;
89

@@ -25,19 +26,16 @@ pub const BLAKE_2B128_SIZE: usize = 128 / 8;
2526
pub type Blake2b128Hash = Blake2bHash<BLAKE_2B128_SIZE>;
2627

2728
/// Errors that can occur when converting to a `Blake2bHash`.
28-
#[derive(Debug, Error)]
29+
#[derive(Display, Debug, Error)]
2930
pub enum Blake2bHashError {
30-
/// Indicates that the input byte slice has invalid length of bytes to create a valid
31-
/// hash.
32-
#[error("Invalid length: expected {expected} bytes, got {actual}")]
31+
/// Invalid length: expected {expected} bytes, got {actual}
3332
InvalidLength {
3433
/// The expected number of bytes (must be 32 or 28).
3534
expected: usize,
3635
/// The actual number of bytes in the provided input.
3736
actual: usize,
3837
},
39-
/// The input string is not a valid hex-encoded string.
40-
#[error("Invalid hex string: {source}")]
38+
/// Invalid hex string: {source}
4139
InvalidHex {
4240
/// The underlying error from `hex`.
4341
#[from]
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,33 @@
11
//! Errors returned by this type
22
3+
use displaydoc::Display;
34
use thiserror::Error;
45

56
use super::{key_rotation::KeyRotationError, role_index::RoleIndexError};
67

78
/// Errors that can occur when parsing a `KidUri`
8-
#[derive(Error, Debug)]
9+
#[derive(Display, Error, Debug)]
910
pub enum KidUriError {
1011
/// Invalid KID URI
11-
#[error("Invalid URI")]
1212
InvalidURI(#[from] fluent_uri::error::ParseError),
1313
/// Invalid Scheme, not a KID URI
14-
#[error("Invalid Scheme, not a KID URI")]
1514
InvalidScheme,
1615
/// Network not defined in URI
17-
#[error("No defined Network")]
1816
NoDefinedNetwork,
1917
/// Path of URI is invalid
20-
#[error("Invalid Path")]
2118
InvalidPath,
2219
/// Role 0 Key in path is invalid
23-
#[error("Invalid Role 0 Key")]
2420
InvalidRole0Key,
2521
/// Role 0 Key in path is not encoded correctly
26-
#[error("Invalid Role 0 Key Encoding")]
2722
InvalidRole0KeyEncoding(#[from] base64_url::base64::DecodeError),
2823
/// Role Index is invalid
29-
#[error("Invalid Role")]
3024
InvalidRole,
3125
/// Role Index is not encoded correctly
32-
#[error("Invalid Role Index")]
3326
InvalidRoleIndex(#[from] RoleIndexError),
3427
/// Role Key Rotation is invalid
35-
#[error("Invalid Rotation")]
3628
InvalidRotation,
3729
/// Role Key Rotation is not encoded correctly
38-
#[error("Invalid Rotation Value")]
3930
InvalidRotationValue(#[from] KeyRotationError),
4031
/// Encryption key Identifier Fragment is not valid
41-
#[error("Invalid Encryption Key Fragment")]
4232
InvalidEncryptionKeyFragment,
4333
}

rust/catalyst-types/src/kid_uri/key_rotation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ use std::{
66
str::FromStr,
77
};
88

9+
use displaydoc::Display;
910
use thiserror::Error;
1011

1112
/// Errors from parsing the `KeyRotation`
12-
#[derive(Error, Debug)]
13+
#[derive(Display, Error, Debug)]
1314
#[allow(clippy::module_name_repetitions)]
1415
pub enum KeyRotationError {
15-
/// Key Rotation could not be parsed from a string
16-
#[error("Invalid Role Key Rotation")]
16+
/// Invalid Role Key Rotation
1717
InvalidRole(#[from] ParseIntError),
1818
}
1919

rust/catalyst-types/src/kid_uri/role_index.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ use std::{
66
str::FromStr,
77
};
88

9+
use displaydoc::Display;
910
use thiserror::Error;
1011

1112
/// Role Index parsing error
12-
#[derive(Error, Debug)]
13+
#[derive(Display, Error, Debug)]
1314
#[allow(clippy::module_name_repetitions)]
1415
pub enum RoleIndexError {
15-
/// Failed to parse the role index
16-
#[error("Invalid Role Index")]
16+
/// Invalid Role Index
1717
InvalidRole(#[from] ParseIntError),
1818
}
1919

rust/catalyst-types/src/uuid/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! `UUID` types.
22
3+
use displaydoc::Display;
34
use thiserror::Error;
45
use uuid::Uuid;
56

@@ -16,16 +17,13 @@ pub const INVALID_UUID: uuid::Uuid = uuid::Uuid::from_bytes([0x00; 16]);
1617
pub const UUID_CBOR_TAG: u64 = 37;
1718

1819
/// Errors that can occur when decoding CBOR-encoded UUIDs.
19-
#[derive(Debug, Error)]
20+
#[derive(Display, Debug, Error)]
2021
pub enum CborUuidError {
21-
/// Indicates that the CBOR value is not a valid UUID tag.
22-
#[error("Invalid CBOR encoded UUID type")]
22+
/// Invalid CBOR encoded UUID type
2323
InvalidCborType,
24-
/// Indicates that the byte slice has an invalid size for a UUID.
25-
#[error("Invalid CBOR encoded UUID type: invalid bytes size")]
24+
/// Invalid CBOR encoded UUID type: invalid bytes size
2625
InvalidByteSize,
27-
/// Indicates that the UUID version does not match the expected version.
28-
#[error("UUID {uuid} is not `v{expected_version}`")]
26+
/// UUID {uuid} is not `v{expected_version}`
2927
InvalidVersion {
3028
/// The decoded UUID that was checked.
3129
uuid: Uuid,

0 commit comments

Comments
 (0)