Enum sp_rpc::number::NumberOrHex
source · [−]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
Number(u64)
The number represented directly.
Hex(U256)
Hex representation of the number.
Implementations
sourceimpl NumberOrHex
impl NumberOrHex
Trait Implementations
sourceimpl Clone for NumberOrHex
impl Clone for NumberOrHex
sourcefn clone(&self) -> NumberOrHex
fn clone(&self) -> NumberOrHex
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for NumberOrHex
impl Debug for NumberOrHex
sourceimpl Default for NumberOrHex
impl Default for NumberOrHex
sourceimpl<'de> Deserialize<'de> for NumberOrHex
impl<'de> Deserialize<'de> for NumberOrHex
sourcefn 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
sourceimpl From<NumberOrHex> for U256
impl From<NumberOrHex> for U256
sourcefn from(num_or_hex: NumberOrHex) -> U256
fn from(num_or_hex: NumberOrHex) -> U256
Performs the conversion.
sourceimpl PartialEq<NumberOrHex> for NumberOrHex
impl PartialEq<NumberOrHex> for NumberOrHex
sourcefn 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 ==
. Read more
sourcefn ne(&self, other: &NumberOrHex) -> bool
fn ne(&self, other: &NumberOrHex) -> bool
This method tests for !=
.
sourceimpl Serialize for NumberOrHex
impl Serialize for NumberOrHex
sourceimpl 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.
sourceimpl 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.
sourceimpl 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.
impl Copy for NumberOrHex
impl StructuralPartialEq for NumberOrHex
Auto Trait Implementations
impl RefUnwindSafe for NumberOrHex
impl Send for NumberOrHex
impl Sync for NumberOrHex
impl Unpin for NumberOrHex
impl UnwindSafe for NumberOrHex
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.