Skip to main content

YamlValue

Trait YamlValue 

Source
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§

Source

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.

Source

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§

Source

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".

Implementations on Foreign Types§

Source§

impl YamlValue for String

Source§

impl YamlValue for bool

Source§

impl YamlValue for char

Source§

impl YamlValue for f32

Source§

impl YamlValue for f64

Source§

impl YamlValue for i8

Source§

fn read_yaml(doc: &YamlDoc, node: NodeId) -> Result<i8, YamlError>

Source§

fn write_yaml( &self, doc: &mut YamlDoc, node: Option<NodeId>, ) -> Result<NodeId, YamlError>

Source§

impl YamlValue for i16

Source§

impl YamlValue for i32

Source§

impl YamlValue for i64

Source§

impl YamlValue for i128

Source§

impl YamlValue for isize

Source§

impl YamlValue for u8

Source§

fn read_yaml(doc: &YamlDoc, node: NodeId) -> Result<u8, YamlError>

Source§

fn write_yaml( &self, doc: &mut YamlDoc, node: Option<NodeId>, ) -> Result<NodeId, YamlError>

Source§

impl YamlValue for u16

Source§

impl YamlValue for u32

Source§

impl YamlValue for u64

Source§

impl YamlValue for u128

Source§

impl YamlValue for usize

Source§

impl<T, S> YamlValue for HashMap<String, T, S>

Source§

fn read_yaml( doc: &YamlDoc, node: NodeId, ) -> Result<HashMap<String, T, S>, YamlError>

Source§

fn write_yaml( &self, doc: &mut YamlDoc, node: Option<NodeId>, ) -> Result<NodeId, YamlError>

Source§

impl<T, const N: usize> YamlValue for [T; N]

Source§

impl<T> YamlValue for BTreeMap<String, T>

Source§

fn read_yaml( doc: &YamlDoc, node: NodeId, ) -> Result<BTreeMap<String, T>, YamlError>

Source§

fn write_yaml( &self, doc: &mut YamlDoc, node: Option<NodeId>, ) -> Result<NodeId, YamlError>

Source§

impl<T> YamlValue for Box<T>
where T: YamlValue,

Source§

fn read_yaml_field( doc: &YamlDoc, node: Option<NodeId>, key: &str, ) -> Result<Box<T>, YamlError>

Source§

fn read_yaml(doc: &YamlDoc, node: NodeId) -> Result<Box<T>, YamlError>

Source§

fn write_yaml( &self, doc: &mut YamlDoc, node: Option<NodeId>, ) -> Result<NodeId, YamlError>

Source§

impl<T> YamlValue for Option<T>
where T: YamlValue,

Source§

fn read_yaml_field( doc: &YamlDoc, node: Option<NodeId>, _key: &str, ) -> Result<Option<T>, YamlError>

Source§

fn read_yaml(doc: &YamlDoc, node: NodeId) -> Result<Option<T>, YamlError>

Source§

fn write_yaml( &self, doc: &mut YamlDoc, node: Option<NodeId>, ) -> Result<NodeId, YamlError>

Source§

impl<T> YamlValue for Vec<T>

Source§

fn read_yaml(doc: &YamlDoc, node: NodeId) -> Result<Vec<T>, YamlError>

Source§

fn write_yaml( &self, doc: &mut YamlDoc, node: Option<NodeId>, ) -> Result<NodeId, YamlError>

Implementors§