pub fn from_bytes<'a, T>(s: &'a [u8]) -> Result<T, SpannedError>where
T: Deserialize<'a>,
Expand description
A convenience function for building a deserializer
and deserializing a value of type T
from bytes.
Examples found in repository?
examples/asset/custom_asset.rs (line 47)
38 39 40 41 42 43 44 45 46 47 48 49 50
fn load<'a>(
&'a self,
reader: &'a mut Reader,
_settings: &'a (),
_load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
Box::pin(async move {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
let custom_asset = ron::de::from_bytes::<CustomAsset>(&bytes)?;
Ok(custom_asset)
})
}