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.