pub struct DataHelpers;Expand description
Stateless JSON, base64, and token helpers.
Implementations§
Source§impl DataHelpers
impl DataHelpers
Sourcepub fn serialize<T: Serialize>(value: &T) -> Result<String, Error>
pub fn serialize<T: Serialize>(value: &T) -> Result<String, Error>
Serializes a value to a JSON string. Returns an error when serialization fails.
Sourcepub fn deserialize<T: DeserializeOwned>(s: &str) -> Result<T, Error>
pub fn deserialize<T: DeserializeOwned>(s: &str) -> Result<T, Error>
Deserializes a value from a JSON string. Returns an error on invalid input.
Sourcepub fn from_base64(s: &str) -> Result<String, DecodeError>
pub fn from_base64(s: &str) -> Result<String, DecodeError>
Decodes standard base64 to a string, replacing invalid UTF-8 sequences. Returns an error when the input is not valid base64.
Sourcepub fn create_token(len: usize) -> String
pub fn create_token(len: usize) -> String
Creates a random alphanumeric token of length len.
Auto Trait Implementations§
impl Freeze for DataHelpers
impl RefUnwindSafe for DataHelpers
impl Send for DataHelpers
impl Sync for DataHelpers
impl Unpin for DataHelpers
impl UnsafeUnpin for DataHelpers
impl UnwindSafe for DataHelpers
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
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> ⓘ
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 more