hcl::format

Trait Format

Source
pub trait Format: Sealed {
    // Required method
    fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>
       where W: Write;

    // Provided methods
    fn format_vec<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<Vec<u8>>
       where W: Write + AsMut<Vec<u8>> { ... }
    fn format_string<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<String>
       where W: Write + AsMut<Vec<u8>> { ... }
}
Expand description

A trait to format data structures as HCL.

This trait is sealed to prevent implementation outside of this crate.

Required Methods§

Source

fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>
where W: Write,

Formats a HCL structure using a formatter and writes the result to the provided writer.

§Errors

Formatting the data structure or writing to the writer may fail with an Error.

Provided Methods§

Source

fn format_vec<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<Vec<u8>>
where W: Write + AsMut<Vec<u8>>,

Formats a HCL structure using a formatter and returns the result as a Vec<u8>.

§Errors

Formatting the data structure or writing to the writer may fail with an Error.

Source

fn format_string<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<String>
where W: Write + AsMut<Vec<u8>>,

Formats a HCL structure using a formatter and returns the result as a String.

§Errors

Formatting the data structure or writing to the writer may fail with an Error.

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.

Implementations on Foreign Types§

Source§

impl Format for String

Source§

fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>
where W: Write,

Source§

impl<T> Format for &T
where T: Format,

Source§

fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>
where W: Write,

Implementors§