Crates.io | atelier_core |
lib.rs | atelier_core |
version | 0.2.22 |
source | src |
created_at | 2020-06-22 02:56:06.180956 |
updated_at | 2021-07-02 18:06:06.264446 |
description | Rust native core model for the AWS Smithy IDL. |
homepage | |
repository | https://github.com/johnstonskj/rust-atelier.git |
max_upload_size | |
id | 256539 |
size | 477,208 |
This crate provides a Rust native core model for the AWS Smithy Interface Definition Language.
This crate is the foundation for the Atelier set of crates, and provides the following components:
error
module to be used by all Atelier crates.The following example demonstrates the builder interface to create a model for a simple service. The
service, MessageOfTheDay
has a single resource Message
. The resource has an identifier for the
date, but the read
operation does not make the date member required and so will return the message
for the current date.
use atelier_core::builder::traits::ErrorSource;
use atelier_core::model::builder::values::{ArrayBuilder, ObjectBuilder};
use atelier_core::model::builder::{
Builder, ListBuilder, MemberBuilder, ModelBuilder, OperationBuilder, ResourceBuilder,
ServiceBuilder, ShapeTraits, SimpleShapeBuilder, StructureBuilder, TraitBuilder,
};
use atelier_core::model::{Identifier, Model, ShapeID};
fn make_model() -> Model {
ModelBuilder::new(Version::V10, "example.motd")
.service(
ServiceBuilder::new("MessageOfTheDay", "2020-06-21")
.documentation("Provides a Message of the day.")
.resource("Message")
.into(),
)
.resource(
ResourceBuilder::new("Message")
.identifier("date", "Date")
.read("GetMessage")
.into(),
)
.simple_shape(
SimpleShapeBuilder::string("Date")
.apply_trait(traits::pattern(r"^\d\d\d\d\-\d\d-\d\d$"))
.into(),
)
.operation(
OperationBuilder::new("GetMessage")
.readonly()
.input("GetMessageInput")
.output("GetMessageOutput")
.error("BadDateValue")
.into(),
)
.structure(
StructureBuilder::new("GetMessageInput")
.member("date", "Date")
.into(),
)
.structure(
StructureBuilder::new("GetMessageOutput")
.add_member(MemberBuilder::string("message").required().into())
.into(),
)
.structure(
StructureBuilder::new("BadDateValue")
.error_source(ErrorSource::Client)
.add_member(MemberBuilder::string("errorMessage").required().into())
.into(),
)
.into()
}
The example weather_builder.rs
in the examples
directory uses the complete example from the Smithy quick start guide. The
examples
directory also includes a pair of stand-alone examples, using the semantic model and builder APIs, for the
message of the day service shown in the example above.
As usual these can be executed via cargo in the following manner.
$ cargo run --example weather_builder
$ cargo run --example motd_core
$ cargo run --example motd_builder
Version 0.2.22
Version 0.2.21
Version 0.2.20
Version 0.2.19
Version 0.2.18
Version 0.2.17
Version 0.2.16
Version 0.2.14
Version 0.2.14
Version 0.2.13
Version 0.2.12
Version 0.2.11
Version 0.2.10
Version 0.2.9
Version 0.2.8
Version 0.2.7
Model::add_metadata
method to perform the Smithy required merge/conflict checks.Model::add_shape
method to perform the Smithy required shape merge/conflict checks.HasTraits::apply_with_value
method to perform the Smithy required trait merge/conflict checks.
HashMap
not Vec
as Smithy only allows the
same trait to be applied once.Version 0.2.6
Version 0.2.5
shape_selector!
macro.PartialEq
to all model types to enable more testing.ExpressionListBuilder
to SelectorBuilder
.Version 0.2.3
Selector
models.ShapeType::All
to ShapeType::Any
.Version 0.2.3
Selector
models.Version 0.2.2
HasIdentity
and HasTraits
traits to allow doc writer to be polymorphic.Version 0.2.1
MutableModelVisitor
trait.Version 0.2.0
Version 0.1.5
UnwelcomeTerms
linter.ModelReader
and ModelWriter
;
representation
methodActionIssue
an std::error::Error
.ModelVisitor
to action
module.Model::merge
method.Version 0.1.4
NoOrphanedReferences
validator.CorrectTypeReferences
validator.NamingConventions
linter.run_linter_actions
and run_validation_actions
, and removed ValidateAll
type.REPRESENTATION
to representation()
on ModelReader
and ModelWriter
traits.Version 0.1.3
Writer
implementations features.syntax
for all string constants.ShapeID
s to the module prelude
.Model::resolve_id
according to the Smithy spec.Version 0.1.2
Updated the model and builder APIs to support JSON and Smithy readers:
HasMembers
trait for a more un-typed API,Finished the API documentation.
Version 0.1.1
build
methods to use Into<T>
,Version 0.1.0