ToYaml

Trait ToYaml 

Source
pub trait ToYaml: Serialize + Sized {
    // Provided method
    fn to_yaml(&self) -> Result<String, YamlError> { ... }
}
Available on crate feature yaml only.
Expand description

Extension trait for serializing types to YAML.

This trait is implemented for all types that implement Serialize. It provides a convenient to_yaml() method for generating YAML strings.

§Example

use clawspec_core::ToYaml;
use utoipa::openapi::OpenApi;

let spec: OpenApi = /* ... */;
let yaml = spec.to_yaml()?;
println!("{yaml}");

Provided Methods§

Source

fn to_yaml(&self) -> Result<String, YamlError>

Serializes this value to a YAML string.

§Errors

Returns a YamlError if serialization fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Serialize + Sized> ToYaml for T