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> Send for With<E>where
E: Send,
impl<E> Sync for With<E>where
E: Sync,
impl<E> RefUnwindSafe for With<E>where
E: RefUnwindSafe,
impl<E> Unpin for With<E>where
E: Unpin,
impl<E> UnwindSafe for With<E>where
E: UnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§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