mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 17:18:08 -05:00
chore(rpc): add convenience from impl (#1686)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
use reth_primitives::U256;
|
||||
use serde::{
|
||||
de::{Error, Visitor},
|
||||
Deserialize, Deserializer, Serialize, Serializer,
|
||||
};
|
||||
use std::fmt;
|
||||
|
||||
/// A hex encoded or decimal index
|
||||
/// A hex encoded or decimal index that's intended to be used as a rust index, hence it's
|
||||
/// deserialized into a `usize`.
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Default)]
|
||||
pub struct Index(usize);
|
||||
|
||||
@@ -14,6 +16,12 @@ impl From<Index> for usize {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Index> for U256 {
|
||||
fn from(idx: Index) -> Self {
|
||||
U256::from(idx.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for Index {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user