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§
source§impl NumberOrHex
impl NumberOrHex
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<NumberOrHex> for NumberOrHex
impl PartialEq<NumberOrHex> 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 RefUnwindSafe for NumberOrHex
impl Send for NumberOrHex
impl Sync for NumberOrHex
impl Unpin for NumberOrHex
impl UnwindSafe for NumberOrHex
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
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
.