Skip to main content

from_slice

Function from_slice 

Source
pub fn from_slice<T: DeserializeOwned>(data: &[u8]) -> Result<T>
Expand description

Deserialize an entire in-memory ABX document into T, using its root element. The one-shot entry point for “this whole document is one struct” — no parser to construct, no element name to spell out. Matches quick-xml’s from_str/serde_json’s from_slice: the root’s tag name is not checked against T at all, so name your types however you like.

For a document whose interesting content is repeated elements nested under an outer wrapper (e.g. AOSP’s packages.xml), use crate::AbxParser::deserialize_all/deserialize_iter instead — this function is for when the root itself is the record you want.