pub struct GraphSerializer;Expand description
Serializer/deserializer for shader graphs in a custom TOML-like text format.
§Format
[graph]
name = "my_shader"
next_id = 42
[[node]]
id = 1
type = "Color"
label = "Base Color"
enabled = true
editor_x = 100.0
editor_y = 200.0
input.0.default = "vec4:1.0,0.0,0.0,1.0"
property.my_key = "float:0.5"
[[connection]]
from = 1:0
to = 3:1Implementations§
Source§impl GraphSerializer
impl GraphSerializer
Sourcepub fn serialize(graph: &ShaderGraph) -> String
pub fn serialize(graph: &ShaderGraph) -> String
Serialize a shader graph to the custom text format.
Sourcepub fn deserialize(input: &str) -> Result<ShaderGraph, SerializeError>
pub fn deserialize(input: &str) -> Result<ShaderGraph, SerializeError>
Deserialize a shader graph from the custom text format.
Sourcepub fn round_trip(graph: &ShaderGraph) -> Result<ShaderGraph, SerializeError>
pub fn round_trip(graph: &ShaderGraph) -> Result<ShaderGraph, SerializeError>
Serialize a graph to a string, then deserialize it back. Returns the round-tripped graph. Useful for testing fidelity.
Sourcepub fn verify_round_trip(
graph: &ShaderGraph,
) -> Result<Vec<String>, SerializeError>
pub fn verify_round_trip( graph: &ShaderGraph, ) -> Result<Vec<String>, SerializeError>
Verify round-trip fidelity: serialize, deserialize, and check equality.
Auto Trait Implementations§
impl Freeze for GraphSerializer
impl RefUnwindSafe for GraphSerializer
impl Send for GraphSerializer
impl Sync for GraphSerializer
impl Unpin for GraphSerializer
impl UnsafeUnpin for GraphSerializer
impl UnwindSafe for GraphSerializer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.