pub trait YamlValue: Sized {
// Required methods
fn read_yaml(doc: &YamlDoc, node: NodeId) -> Result<Self, YamlError>;
fn write_yaml(
&self,
doc: &mut YamlDoc,
node: Option<NodeId>,
) -> Result<NodeId, YamlError>;
// Provided method
fn read_yaml_field(
doc: &YamlDoc,
node: Option<NodeId>,
key: &str,
) -> Result<Self, YamlError> { ... }
}Expand description
Reads and writes individual YAML node values.
Required Methods§
Sourcefn read_yaml(doc: &YamlDoc, node: NodeId) -> Result<Self, YamlError>
fn read_yaml(doc: &YamlDoc, node: NodeId) -> Result<Self, YamlError>
Reads a typed value from node.
§Errors
Returns an error when node is unknown, has an unsupported YAML kind, or
cannot be decoded as Self.
Sourcefn write_yaml(
&self,
doc: &mut YamlDoc,
node: Option<NodeId>,
) -> Result<NodeId, YamlError>
fn write_yaml( &self, doc: &mut YamlDoc, node: Option<NodeId>, ) -> Result<NodeId, YamlError>
Writes a typed value into an existing node or inserts a new node.
§Errors
Returns an error when the value cannot be represented in the target YAML shape, when insertion requires a missing parent context, or when the edit cannot be queued.
Provided Methods§
Sourcefn read_yaml_field(
doc: &YamlDoc,
node: Option<NodeId>,
key: &str,
) -> Result<Self, YamlError>
fn read_yaml_field( doc: &YamlDoc, node: Option<NodeId>, key: &str, ) -> Result<Self, YamlError>
Reads a mapping field that may be absent.
The default implementation reports a missing required field. Container
types such as Option may override this to define missing-field
semantics without requiring derive-time type inspection.
§Errors
Returns an error when a required field is absent or the selected node
cannot be decoded as Self.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".