[][src]Module atelier_core::io

Traits for reading and writing models in different formats. Separate crates implement the ability to handle different representations, such as the original Smithy, JSON AST, and OpenAPI.

This module also provides some useful Writer implementations, all are features, all are included by default.

  • debug; uses the Debug implementation of Model to write out the internal structure.
  • uml; uses PlantUML to generate diagrams of a model structure.

Example Model Writer

The example below is pretty much the implementation of the debug module, it writes the model using the Debug implementation associated with those objects.

#[derive(Debug)]
pub struct Debugger {}

impl Default for Debugger {
    fn default() -> Self {
        Self {}
    }
}

impl<'a> ModelWriter<'a> for Debugger {
    const REPRESENTATION: &'static str = "Debug";

    fn write(&mut self, w: &mut impl Write, model: &'a Model) -> Result<()> {
        write!(w, "{:#?}", model)?;
        Ok(())
    }
}

Modules

debug

A simple implementation of the ModelWriter trait that simply uses the Debug trait. This allows the easy swapping in of a sanity check as different reader/writer implementations are used.

plant_uml

Writer to produce PlantUML text files for diagramming.

Traits

ModelReader

Trait implemented to read a model from a specific representation.

ModelWriter

Trait implemented to write a model in a specific representation.

Functions

read_model_from_string

Read a model from the string-like value s using the given ModelReader. This is simply a short-cut that saves some repetitive boiler-plate.

write_model_to_string

Write the model into a string s using the given ModelWriter. This is simply a short-cut that saves some repetitive boiler-plate.