pub fn from_slice<T: DeserializeOwned>(data: &[u8]) -> Result<T>Available on crate feature
serde only.Expand description
Deserializes the root element of an ABX document into T.
The root’s tag name is not checked. See Deserializing with serde for how fields are matched.
§Errors
Returns a parse error if the input is malformed, or
AbxError::Deserialization if the document has no root element or it does
not match T.
§Examples
use serde::Deserialize;
#[derive(Deserialize)]
struct Pkg {
name: String,
version: u32,
}
let pkg: Pkg = android_abx::from_slice(data)?;
assert_eq!(pkg.name, "com.example.chat");
assert_eq!(pkg.version, 3);