stratus/eth/primitives/
miner_nonce.rs1use alloy_primitives::B64;
2use display_json::DebugAsJson;
3#[cfg(test)]
4use fake::Dummy;
5#[cfg(test)]
6use fake::Faker;
7
8#[derive(DebugAsJson, derive_more::Display, Clone, Copy, Default, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
10pub struct MinerNonce(B64);
11
12#[cfg(test)]
13impl Dummy<Faker> for MinerNonce {
14 fn dummy_with_rng<R: rand::Rng + ?Sized>(_: &Faker, rng: &mut R) -> Self {
15 B64::random_with(rng).into()
16 }
17}
18
19impl From<B64> for MinerNonce {
24 fn from(value: B64) -> Self {
25 Self(value)
26 }
27}
28
29impl From<[u8; 8]> for MinerNonce {
30 fn from(value: [u8; 8]) -> Self {
31 Self(B64::from(value))
32 }
33}
34
35impl From<MinerNonce> for B64 {
39 fn from(value: MinerNonce) -> Self {
40 value.0
41 }
42}
43
44impl From<MinerNonce> for [u8; 8] {
45 fn from(value: MinerNonce) -> Self {
46 B64::from(value).0
47 }
48}