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§
source§impl<E> With<E>
impl<E> With<E>
sourcepub fn serialize<T: Encodable, S: Serializer>(
value: &T,
serializer: S
) -> Result<S::Ok, S::Error>where
E: ByteEncoder,
pub fn serialize<T: Encodable, S: Serializer>( value: &T, serializer: S ) -> Result<S::Ok, S::Error>where E: ByteEncoder,
Serializes the value as consensus-encoded
sourcepub fn deserialize<'d, T: Decodable, D: Deserializer<'d>>(
deserializer: D
) -> Result<T, D::Error>where
for<'a> E: ByteDecoder<'a>,
pub fn deserialize<'d, T: Decodable, D: Deserializer<'d>>( deserializer: D ) -> Result<T, D::Error>where for<'a> E: ByteDecoder<'a>,
Deserializes the value as consensus-encoded
Auto Trait Implementations§
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