Struct With
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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request