pub struct BytesWrapper<T, O> {
inner: T,
phantom: PhantomData<O>,
}Expand description
Wraps a type T that uses the byte array serde data type for serialization so
that the serde string data type is used instead,
according to BytesEncoding O::Encoding.
Due to the generic (de)serialize implementation, the standard types
Vec<u8>, &[u8], [u8,N], … use the sequence serde data type instead of byte array.
Use serde_bytes::Bytes, serde_bytes::ByteBuf, and ByteArray instead.
(Or use ChangeVisitorType to change the visitor type to VisitorType::ByteSequence.)
We primarily use this to encode keys as hex or base64 strings in JSON instead of arrays.
Fields§
§inner: T§phantom: PhantomData<O>Implementations§
Source§impl<T, O> BytesWrapper<T, O>
impl<T, O> BytesWrapper<T, O>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the wrapped object.
Note: We cannot implement Into<T> for BytesWrapper, because it would clash
with the implementation of Into<T> when T implements From<BytesWrapper>.
pub fn new(inner: T) -> Self
Trait Implementations§
Source§impl<T: Clone, O> Clone for BytesWrapper<T, O>
impl<T: Clone, O> Clone for BytesWrapper<T, O>
Source§impl<T: Debug, O> Debug for BytesWrapper<T, O>
impl<T: Debug, O> Debug for BytesWrapper<T, O>
Source§impl<T: Default, O> Default for BytesWrapper<T, O>
impl<T: Default, O> Default for BytesWrapper<T, O>
Source§impl<T, O> Deref for BytesWrapper<T, O>
impl<T, O> Deref for BytesWrapper<T, O>
Source§impl<T, O> DerefMut for BytesWrapper<T, O>
impl<T, O> DerefMut for BytesWrapper<T, O>
Source§impl<'de, T, O: Options> Deserialize<'de> for BytesWrapper<T, O>
impl<'de, T, O: Options> Deserialize<'de> for BytesWrapper<T, O>
Source§fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T, O: Options> Display for BytesWrapper<T, O>
impl<T, O: Options> Display for BytesWrapper<T, O>
Source§impl From<BytesWrapper<ByteBuf, (B64Encoding<Base64UrlUnpadded>,)>> for EnterNonce
impl From<BytesWrapper<ByteBuf, (B64Encoding<Base64UrlUnpadded>,)>> for EnterNonce
Source§impl From<BytesWrapper<ByteBuf, (B64Encoding<Base64UrlUnpadded>,)>> for EnterState
impl From<BytesWrapper<ByteBuf, (B64Encoding<Base64UrlUnpadded>,)>> for EnterState
Source§impl<T> From<BytesWrapper<ByteBuf, (B64Encoding<Base64UrlUnpadded>,)>> for Sealed<T>where
T: Signable,
impl<T> From<BytesWrapper<ByteBuf, (B64Encoding<Base64UrlUnpadded>,)>> for Sealed<T>where
T: Signable,
Source§impl<T, O> From<T> for BytesWrapper<T, O>
impl<T, O> From<T> for BytesWrapper<T, O>
Source§impl<T, O: Options> FromStr for BytesWrapper<T, O>
impl<T, O: Options> FromStr for BytesWrapper<T, O>
Source§impl<T: Hash, O> Hash for BytesWrapper<T, O>
impl<T: Hash, O> Hash for BytesWrapper<T, O>
Source§impl<T: Ord, O> Ord for BytesWrapper<T, O>
impl<T: Ord, O> Ord for BytesWrapper<T, O>
Source§impl<T: PartialEq, O> PartialEq for BytesWrapper<T, O>
impl<T: PartialEq, O> PartialEq for BytesWrapper<T, O>
Source§impl<T: PartialOrd, O> PartialOrd for BytesWrapper<T, O>
impl<T: PartialOrd, O> PartialOrd for BytesWrapper<T, O>
Source§impl<T, O: Options> Serialize for BytesWrapper<T, O>
impl<T, O: Options> Serialize for BytesWrapper<T, O>
impl<T: Copy, O> Copy for BytesWrapper<T, O>
impl<T: Eq, O> Eq for BytesWrapper<T, O>
Auto Trait Implementations§
impl<T, O> Freeze for BytesWrapper<T, O>where
T: Freeze,
impl<T, O> RefUnwindSafe for BytesWrapper<T, O>where
T: RefUnwindSafe,
O: RefUnwindSafe,
impl<T, O> Send for BytesWrapper<T, O>
impl<T, O> Sync for BytesWrapper<T, O>
impl<T, O> Unpin for BytesWrapper<T, O>
impl<T, O> UnsafeUnpin for BytesWrapper<T, O>where
T: UnsafeUnpin,
impl<T, O> UnwindSafe for BytesWrapper<T, O>where
T: UnwindSafe,
O: UnwindSafe,
Blanket Implementations§
Source§impl<R> TryRngCore for Rwhere
R: TryRng,
impl<R> TryRngCore for Rwhere
R: TryRng,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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>
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> PayloadTrait for T
impl<T> PayloadTrait for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
random to avoid conflict with the new gen keyword in Rust 2024.Rng::random.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
random_rangeRng::random_range.Source§impl<R> RngExt for R
impl<R> RngExt for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.
Source§impl<R> TryRng for R
impl<R> TryRng for R
Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
RngCore to a RngReadAdapter.