pub struct ChainId(pub u64);Expand description
The chain identifier for Tenzro Network
Used to prevent cross-chain replay attacks and identify the network.
Deserialization enforces the EIP-2294 range [1, (u64::MAX / 2) - 36]
to reject obviously-bad chain ids early (HIGH #70 in the production audit).
Tuple Fields§
§0: u64Implementations§
Source§impl ChainId
impl ChainId
Sourcepub fn new(id: u64) -> Self
pub fn new(id: u64) -> Self
Creates a new ChainId without validation.
Prefer ChainId::try_new when constructing from untrusted input.
Sourcepub fn try_new(id: u64) -> Result<Self, TenzroError>
pub fn try_new(id: u64) -> Result<Self, TenzroError>
Creates a new ChainId, returning an error if id is outside the
allowed range [CHAIN_ID_MIN, CHAIN_ID_MAX].
The upper bound ((u64::MAX / 2) - 36) follows EIP-2294 to avoid
overflow when combined with EIP-155 transaction signing.
Trait Implementations§
impl Copy for ChainId
Source§impl<'de> Deserialize<'de> for ChainId
impl<'de> Deserialize<'de> for ChainId
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ChainId
impl StructuralPartialEq for ChainId
Auto Trait Implementations§
impl Freeze for ChainId
impl RefUnwindSafe for ChainId
impl Send for ChainId
impl Sync for ChainId
impl Unpin for ChainId
impl UnsafeUnpin for ChainId
impl UnwindSafe for ChainId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more