#idl #smithy #parse #model

atelier_smithy

Rust native Smithy language format for the AWS Smithy IDL

19 releases

0.2.13 Jun 25, 2021
0.2.12 Jun 25, 2021
0.2.9 May 21, 2021
0.2.6 Apr 30, 2021
0.1.1 Jun 30, 2020

#123 in Web programming

Download history 263/week @ 2022-06-12 461/week @ 2022-06-19 98/week @ 2022-06-26 450/week @ 2022-07-03 1064/week @ 2022-07-10 472/week @ 2022-07-17 382/week @ 2022-07-24 304/week @ 2022-07-31 256/week @ 2022-08-07 410/week @ 2022-08-14 579/week @ 2022-08-21 389/week @ 2022-08-28 469/week @ 2022-09-04 317/week @ 2022-09-11 264/week @ 2022-09-18 226/week @ 2022-09-25

1,315 downloads per month
Used in 25 crates (3 directly)

MIT license

485KB
10K SLoC

Atelier: crate atelier_smithy

Provides the ability to read and write Smithy models in its own native language representation.

crates.io docs.rs

The crate provides two low-level parsers, parse_model and parse_selector that correspond to the core Model and Selector types. These are decouple to allow for the tool use cases where it is unnecessary or even undesirable to parse all selector expressions as well as those cases where selector expressions may be useful in non-model scenarios.

This crate also provides implementations of both the core ModelReader and ModelWriter traits for Smithy IDL files.

Example

The following demonstrates the SmithyReader to parse a file into the in-memory model.

use atelier_core::io::read_model_from_file;
use atelier_smithy::SmithyReader;
use std::path::PathBuf;

let path = PathBufBuf::from("tests/good/waiters.smithy");
let mut reader = SmithyReader::default();
let result = read_model_from_file(&mut reader, path);
assert!(result.is_ok());

Example - Selector

The following example parses the simple selector expression "*", denoting any shape, into it's in-memory model.

use atelier_smithy::parse_selector;

let result = parse_selector("*");
assert!(result.is_ok());

Changes

Version 0.2.13

Version 0.2.12

  • Changed the ID on MemberShape from ShapeID to Identifier. This matches both the formal BNF for the Smithy IDL and the JSON AST usage.

Version 0.2.11

  • Fixed escaping bug for line writer that made cross-platform comparison a pain.

Version 0.2.10

  • Fixed test case typo.

Version 0.2.9

  • From core: Reorganized errors, made the naming and messages consistent and removed unused.

Version 0.2.8

  • Supporting the core model builders which now use TryFrom instead of From.
  • Support the "renames" collection added to service shapes in the abstract model.
  • All annotation traits use an empty object as value, not None.
  • Using new shared atelier-test crate.

Version 0.2.7

  • Supporting the core model builders which now use TryFrom instead of From.
  • Using new shared atelier-test crate.

Version 0.2.6

  • Updated due to trait API changes in core.

Version 0.2.5

  • Updated Smithy grammar and parser to match changes in the specification:
    • turned the comma "," character into whitespace so it becomes optional as a member separator
    • removed the br rule as to ensure members are defined on separate lines
    • simplified a number of rules that had empty/populated pairs
  • Added two additional test example files

Version 0.2.4

  • Tracking change to ShapeType from atelier_core crate.

Version 0.2.3

  • Added support for parsing selector expressions.

Version 0.2.2

  • Fixed: test case compile error.

Version 0.2.1

  • Changes based on new core traits HasIdentity and HasTraits.

Version 0.2.0

  • Major refactor after agreement on the separation of semantic model with Smithy team.

Version 0.1.5

  • API changes for ModelReader and ModelWriter.
    • removed representation method
    • added FILE_EXTENSION constant.
  • Changed internal module organization to mirror the json crate.

Version 0.1.4

  • Validated round-tripping Smithy files, read into a model then write back out again.

Version 0.1.3

  • Changes to the core API around ModelReader and ModelWriter.

Version 0.1.2

  • Moved most strings to use core::syntax.
  • Fixed issues with multiple documentation strings.
  • Fixed issue with blank documentation traits.
  • Fixed grammar issue with empty trait bodies.

Version 0.1.1

  • Able to parse basic examples.

Version 0.1.0

  • First release.
  • Able to write the example weather service, constructed using the builder API.

TODO

  1. Need to have a parser.

Dependencies

~7.5MB
~165K SLoC