pub struct With<E>(/* private fields */);
Expand description
Helper for #[serde(with = "")]
.
To (de)serialize a field using consensus encoding you can write e.g.:
use bitcoin::Transaction;
use bitcoin::consensus;
#[derive(Serialize, Deserialize)]
pub struct MyStruct {
#[serde(with = "consensus::serde::With::<consensus::serde::Hex>")]
tx: Transaction,
}
Implementations§
§impl<E> With<E>
impl<E> With<E>
pub fn serialize<T, S>(
value: &T,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
pub fn serialize<T, S>( value: &T, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
Serializes the value as consensus-encoded
pub fn deserialize<'d, T, D>(
deserializer: D
) -> Result<T, <D as Deserializer<'d>>::Error>
pub fn deserialize<'d, T, D>( deserializer: D ) -> Result<T, <D as Deserializer<'d>>::Error>
Deserializes the value as consensus-encoded
Auto Trait Implementations§
impl<E> Freeze for With<E>
impl<E> RefUnwindSafe for With<E>where
E: RefUnwindSafe,
impl<E> Send for With<E>where
E: Send,
impl<E> Sync for With<E>where
E: Sync,
impl<E> Unpin for With<E>where
E: Unpin,
impl<E> UnwindSafe for With<E>where
E: UnwindSafe,
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