rkyv_to_json

Function rkyv_to_json 

Source
pub fn rkyv_to_json<T>(rkyv: &[u8]) -> Result<Value, Error>
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 into T.

§Errors

  • Returns Error::Rkyv if:
    • The archive cannot be validated (check_archived_root fails).
    • Deserialization from RKYV to Rust fails.
  • Returns serde_json::Error if JSON serialization fails.