Crate atelier_assembler[][src]

Expand description

This crate provides the model assembly capability, to merge files into a single in-memory Model.

A tool can add files one-by-one, or from a directory, and then process them all into a single model. This implementation understands the different registered file extensions so that it can read files in different representations and assemble them seamlessly.

Example

The following is the simple, and most common, method of using the assembler. This uses the default FileTypeRegistry and will search for all models in the set of paths specified in the environment variable “SMITHY_PATH”.

use atelier_assembler::ModelAssembler;
use atelier_core::error::Result;
use atelier_core::model::Model;
use std::convert::TryFrom;

// The default constructor will load all paths from the `SMITHY_PATH` environment variable.
let env_assembler = ModelAssembler::default();

let model: Result<Model> = Model::try_from(env_assembler);

For more information, see the Rust Atelier book.

Structs

A File type, this has a display name and a reader function. The FileTypeRegistry uses these to map one ot more file types to reader functions (FileReader).

A mapping from file extension to file type. Note that FileTypeRegistry::default will always contain at least mappings for “.json” and “.smithy” file types. Note that file extensions will always be compared in a case insensitive manner.

Assemble a single model by merging the sub-models represented by one or more files. The model assembler uses an instance of FileTypeRegistry to determine the correct file mappings to load different representations. It may also scan an environment variable for a set of paths to load models from as well as any specific files or directories added via push or push_str.

A Search path that can be initialized from an environment variable.

Type Definitions

A Function type used to read a particular format into a model. This type is used by the FileType.