Skip to content

Commit

Permalink
remove thiserror from hash crate
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinheavey committed Jul 17, 2024
1 parent 1a3bfd2 commit 5b0bef1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
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.

1 change: 0 additions & 1 deletion programs/sbf/Cargo.lock

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

1 change: 0 additions & 1 deletion sdk/hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ solana-atomic-u64 = { workspace = true }
solana-frozen-abi = { workspace = true, optional = true }
solana-frozen-abi-macro = { workspace = true, optional = true }
solana-sanitize = { workspace = true }
thiserror = { workspace = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = { workspace = true }
Expand Down
25 changes: 17 additions & 8 deletions sdk/hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use bytemuck_derive::{Pod, Zeroable};
#[cfg(feature = "serde")]
use serde_derive::{Deserialize, Serialize};
use {
core::fmt,
solana_sanitize::Sanitize,
std::{convert::TryFrom, error::Error, mem, str::FromStr},
};
#[cfg(target_arch = "wasm32")]
use {
js_sys::{Array, Uint8Array},
wasm_bindgen::{prelude::*, JsCast},
};
use {
solana_sanitize::Sanitize,
std::{convert::TryFrom, fmt, mem, str::FromStr},
thiserror::Error,
};

/// Size of a hash in bytes.
pub const HASH_BYTES: usize = 32;
Expand Down Expand Up @@ -70,14 +70,23 @@ impl fmt::Display for Hash {
}
}

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ParseHashError {
#[error("string decoded to wrong size for hash")]
WrongSize,
#[error("failed to decoded string to hash")]
Invalid,
}

impl Error for ParseHashError {}

impl fmt::Display for ParseHashError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ParseHashError::WrongSize => f.write_str("string decoded to wrong size for hash"),
ParseHashError::Invalid => f.write_str("failed to decoded string to hash"),
}
}
}

impl FromStr for Hash {
type Err = ParseHashError;

Expand Down

0 comments on commit 5b0bef1

Please sign in to comment.