MCPcopy Create free account
hub / github.com/apache/fory / deserialize

Method deserialize

rust/fory-core/src/fory.rs:987–995  ·  view source on GitHub ↗

Deserializes data from a byte slice into a value of type `T`. # Type Parameters `T` - The target type to deserialize into. Must implement `Serializer` and `ForyDefault`. # Arguments `bf` - The byte slice containing the serialized data. # Returns `Ok(T)` - The deserialized value on success. `Err(Error)` - An error if deserialization fails (e.g., invalid format, type mismatch). # Panics Pani

(&self, bf: &[u8])

Source from the content-addressed store, hash-verified

985 /// let deserialized: Point = fory.deserialize(&bytes).unwrap();
986 /// ```
987 pub fn deserialize<T: Serializer + ForyDefault>(&self, bf: &[u8]) -> Result<T, Error> {
988 self.with_read_context(|context| {
989 let outlive_buffer = unsafe { mem::transmute::<&[u8], &[u8]>(bf) };
990 context.attach_reader(Reader::new(outlive_buffer));
991 let result = self.deserialize_with_context(context);
992 context.detach_reader();
993 result
994 })
995 }
996
997 /// Deserializes data from a `Reader` into a value of type `T`.
998 ///

Calls 4

with_read_contextMethod · 0.80
attach_readerMethod · 0.80
detach_readerMethod · 0.80