Enum sp_rpc::number::NumberOrHex
source · pub enum NumberOrHex {
Number(u64),
Hex(U256),
}
Expand description
A number type that can be serialized both as a number or a string that encodes a number in a string.
We allow two representations of the block number as input. Either we deserialize to the type that is specified in the block type or we attempt to parse given hex value.
The primary motivation for having this type is to avoid overflows when using big integers in JavaScript (which we consider as an important RPC API consumer).
Variants§
Implementations§
Trait Implementations§
source§impl Clone for NumberOrHex
impl Clone for NumberOrHex
source§fn clone(&self) -> NumberOrHex
fn clone(&self) -> NumberOrHex
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for NumberOrHex
impl Debug for NumberOrHex
source§impl Default for NumberOrHex
impl Default for NumberOrHex
source§impl<'de> Deserialize<'de> for NumberOrHex
impl<'de> Deserialize<'de> for NumberOrHex
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
source§impl From<NumberOrHex> for U256
impl From<NumberOrHex> for U256
source§fn from(num_or_hex: NumberOrHex) -> U256
fn from(num_or_hex: NumberOrHex) -> U256
Converts to this type from the input type.
source§impl From<U256> for NumberOrHex
impl From<U256> for NumberOrHex
source§impl From<u128> for NumberOrHex
impl From<u128> for NumberOrHex
source§impl From<u32> for NumberOrHex
impl From<u32> for NumberOrHex
source§impl From<u64> for NumberOrHex
impl From<u64> for NumberOrHex
source§impl PartialEq for NumberOrHex
impl PartialEq for NumberOrHex
source§fn eq(&self, other: &NumberOrHex) -> bool
fn eq(&self, other: &NumberOrHex) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for NumberOrHex
impl Serialize for NumberOrHex
source§impl TryFrom<NumberOrHex> for u128
impl TryFrom<NumberOrHex> for u128
§type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
source§impl TryFrom<NumberOrHex> for u32
impl TryFrom<NumberOrHex> for u32
§type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
source§impl TryFrom<NumberOrHex> for u64
impl TryFrom<NumberOrHex> for u64
§type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
impl Copy for NumberOrHex
impl StructuralPartialEq for NumberOrHex
Auto Trait Implementations§
impl Freeze for NumberOrHex
impl RefUnwindSafe for NumberOrHex
impl Send for NumberOrHex
impl Sync for NumberOrHex
impl Unpin for NumberOrHex
impl UnwindSafe for NumberOrHex
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.