pub fn deserialize_using<T, D, E>(
value: &impl Deserialize<T, Strategy<D, E>>,
deserializer: &mut D,
) -> Result<T, E>
Expand description
Deserialize a value using the given deserializer.
Most of the time, deserialize
is a more ergonomic way
to deserialize an archived value.
ยงExample
use rkyv::{
access, api::deserialize_using, de::Pool, rancor::Error, to_bytes,
Archive, Deserialize, Serialize,
};
#[derive(Archive, Serialize, Deserialize)]
struct Example {
name: String,
value: i32,
}
let value = Example {
name: "pi".to_string(),
value: 31415926,
};
let bytes = to_bytes::<Error>(&value).unwrap();
let archived = access::<ArchivedExample, Error>(&bytes).unwrap();
let deserialized =
deserialize_using::<Example, _, Error>(archived, &mut Pool::new())
.unwrap();