Trait bevy_proto_typetag::data::ProtoDeserializer
source · pub trait ProtoDeserializer: DynClone {
// Required method
fn deserialize(&self, data: &str) -> Option<Box<dyn Prototypical>>;
}
Expand description
Defines a method for deserializing a prototype file input.
Required Methods§
sourcefn deserialize(&self, data: &str) -> Option<Box<dyn Prototypical>>
fn deserialize(&self, data: &str) -> Option<Box<dyn Prototypical>>
Deserializes file input (as a string) into a Prototypical
object
Arguments
data
: The file data as a string
returns: Option<Box<dyn Prototypical, Global>>
Examples
// The default implementation:
use bevy_proto_typetag::{Prototype, Prototypical};
fn example_deserialize(data: &str) -> Option<Box<dyn Prototypical>> {
if let Ok(value) = serde_yaml::from_str::<Prototype>(data) {
Some(Box::new(value))
} else {
None
}
}