Trait UnwrapLazy

Source
pub trait UnwrapLazy {
    // Required method
    fn try_unwrap_lazy(self) -> Result<Self, Error>
       where Self: Sized;

    // Provided method
    fn unwrap_lazy(self) -> Self
       where Self: Sized { ... }
}
Expand description

unwrap_lazy() should fully deserialize any Lazy child fields by calling unwrap_lazy() on all fields. After calling this once, calling this on subfields should be cheap. This crate provides a procedural macro to automatically derive UnwrapLazy. It has also been implemented for many primitive types.

An example:

use lazy_borink::{Lazy, UnwrapLazy};

#[derive(Serialize, Deserialize, UnwrapLazy)]
struct Claims {
    my_claim: String,
}
#[derive(Deserialize, Serialize, UnwrapLazy)]
struct User {
    user_id: String,
    password_file: String,
    claims: Lazy<Claims>,
}
#[derive(Deserialize, Serialize, UnwrapLazy)]
struct UserMeta {
    user: User,
}

The tests provide some additional usage examples.

Required Methods§

Source

fn try_unwrap_lazy(self) -> Result<Self, Error>
where Self: Sized,

Provided Methods§

Source

fn unwrap_lazy(self) -> Self
where Self: Sized,

Implementations on Foreign Types§

Source§

impl UnwrapLazy for bool

Source§

impl UnwrapLazy for char

Source§

impl UnwrapLazy for f32

Source§

impl UnwrapLazy for f64

Source§

impl UnwrapLazy for i8

Source§

impl UnwrapLazy for i16

Source§

impl UnwrapLazy for i32

Source§

impl UnwrapLazy for i64

Source§

impl UnwrapLazy for i128

Source§

impl UnwrapLazy for isize

Source§

impl UnwrapLazy for u8

Source§

impl UnwrapLazy for u16

Source§

impl UnwrapLazy for u32

Source§

impl UnwrapLazy for u64

Source§

impl UnwrapLazy for u128

Source§

impl UnwrapLazy for usize

Source§

impl UnwrapLazy for String

Source§

impl<'a, T> UnwrapLazy for &'a [T]
where T: UnwrapLazy,

Source§

impl<'a, T> UnwrapLazy for &'a mut [T]
where T: UnwrapLazy,

Source§

impl<'a, T> UnwrapLazy for &'a T
where T: UnwrapLazy,

Source§

impl<'a, T> UnwrapLazy for &'a mut T
where T: UnwrapLazy,

Source§

impl<T> UnwrapLazy for Box<T>
where T: UnwrapLazy,

Source§

impl<T> UnwrapLazy for Vec<T>
where T: UnwrapLazy,

Implementors§