pub struct RlpProxy(/* private fields */);Expand description
A proxy for more refined manipulation of data when deserializing.
Here is an example about how to use it.
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
#[serde(from = "RlpProxy")]
enum Classify {
Zero(u8),
One(u8),
Ten((u8, u8))
}
impl From<RlpProxy> for Classify {
fn from(proxy: RlpProxy) -> Self {
let raw = proxy.raw();
let mut tree = proxy.rlp_tree();
if tree.value_count() == 2 {
return Classify::Ten(from_bytes(raw).unwrap())
}
let val = tree.next().unwrap()[0];
match val {
0 => Classify::Zero(0),
1 => Classify::One(1),
_ => panic!("Value Error.")
}
}
}Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RlpProxy
impl<'de> Deserialize<'de> for RlpProxy
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 RlpProxy
impl StructuralPartialEq for RlpProxy
Auto Trait Implementations§
impl Freeze for RlpProxy
impl RefUnwindSafe for RlpProxy
impl Send for RlpProxy
impl Sync for RlpProxy
impl Unpin for RlpProxy
impl UnwindSafe for RlpProxy
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