pub struct MaterialRegistration {
pub type_name: &'static str,
pub serialize: fn(&dyn Material) -> Option<Vec<u8>>,
pub deserialize: MaterialDeserializeFn,
pub create_default: fn() -> Box<dyn Material>,
pub serialize_json: fn(&dyn Material) -> Option<Value>,
pub deserialize_json: fn(&Value) -> Result<Box<dyn Material>, String>,
}Expand description
Registration entry for a serializable material type.
Submitted via inventory::submit! either manually or through #[derive(Material)].
Fields§
§type_name: &'static strUnique type name used for lookup during deserialization.
serialize: fn(&dyn Material) -> Option<Vec<u8>>Serializes a dyn Material into binary data. Returns None if the material
does not match this registration’s concrete type.
deserialize: MaterialDeserializeFnDeserializes binary data back into a Box<dyn Material>.
create_default: fn() -> Box<dyn Material>Creates a default instance of this material type (for placeholder handles).
serialize_json: fn(&dyn Material) -> Option<Value>Serializes a dyn Material into a serde-JSON value for the editor
inspector. Returns None if the material does not match this
registration’s concrete type. Mirrors serialize but in an
editable, human-readable encoding.
deserialize_json: fn(&Value) -> Result<Box<dyn Material>, String>Deserializes a serde-JSON value (as produced by serialize_json) back
into a Box<dyn Material>.