pub fn rkyv_to_json<T>(rkyv: &[u8]) -> Result<Value, Error>where
T: Serialize + Archive,
for<'a> T::Archived: CheckBytes<DefaultValidator<'a>> + Deserialize<T, Infallible>,Expand description
Converts a serialized RKYV archive into a JSON object.
§Parameters
rkyv: A byte slice containing the serialized RKYV data.
§Returns
Ok(JsonValue): A JSON representation of the deserialized object.Err(Error): If deserialization fails.
§Type Parameters
T: The type of the object being deserialized. Must implement:serde::ser::Serialize: Required for JSON conversion.rkyv::Archive: Indicates the type is archivable.CheckBytes<DefaultValidator<'a>>: Ensures safety of archived data.Deserialize<T, Infallible>: Allows deserialization intoT.
§Errors
- Returns
Error::Rkyvif:- The archive cannot be validated (
check_archived_rootfails). - Deserialization from RKYV to Rust fails.
- The archive cannot be validated (
- Returns
serde_json::Errorif JSON serialization fails.