Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57403929b6 | |||
| ec3cad1a05 | |||
| ef0d9f4395 | |||
| 7bd24ff0e7 |
@@ -13,7 +13,7 @@ categories.workspace = true
|
||||
readme.workspace = true
|
||||
|
||||
[workspace.package]
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.81"
|
||||
|
||||
@@ -26,7 +26,7 @@ categories = ["api-bindings"]
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
aws-macros = { path = "./aws_macros", version = "0.2.*" }
|
||||
aws-macros = { path = "./aws_macros", version = "0.3.*" }
|
||||
aws-config = { version = "1.*", default-features = false }
|
||||
aws-sdk-ec2 = { version = "1.*", default-features = false, features = [
|
||||
"rustls",
|
||||
|
||||
5
Makefile
5
Makefile
@@ -7,11 +7,12 @@ docs:
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
@cargo test --workspace --color=always
|
||||
cargo hack --feature-powerset --no-dev-deps check
|
||||
cargo test --workspace --color=always
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
@cargo clippy --workspace --tests --color=always
|
||||
cargo clippy --workspace --tests --color=always
|
||||
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# AWS
|
||||
|
||||
* Helper functions for frequently used AWS operations (create EC2 instance, Route53 record, ...)
|
||||
* Type-safe operations on AWS tags (e.g. from an EC2 instance), see [the separate README](./src/tags/README.md)
|
||||
|
||||
- Helper functions for frequently used AWS operations (create EC2 instance,
|
||||
Route53 record, ...)
|
||||
- Type-safe operations on AWS tags (e.g. from an EC2 instance), see
|
||||
[the separate README](./src/tags/README.md)
|
||||
|
||||
@@ -24,6 +24,25 @@ struct Element {
|
||||
attrs: Vec<syn::Attribute>,
|
||||
}
|
||||
|
||||
fn is_cfg_attribute(attr: &syn::Attribute) -> bool {
|
||||
match attr.meta {
|
||||
syn::Meta::List(ref meta_list) => {
|
||||
let segments = &meta_list.path.segments;
|
||||
match (segments.first(), segments.len()) {
|
||||
(Some(segment), 1) => segment.ident == "cfg",
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn cfg_attrs(v: &[syn::Attribute]) -> Vec<&syn::Attribute> {
|
||||
v.iter()
|
||||
.filter(|attr: &&syn::Attribute| is_cfg_attribute(attr))
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn parse_type(input: syn::Type) -> (syn::Path, ElementKind) {
|
||||
match input {
|
||||
syn::Type::Path(ty) => {
|
||||
@@ -203,7 +222,7 @@ fn build_output(input: Input) -> TokenStream {
|
||||
let params = input.elements.iter().map(|element| {
|
||||
let ident = &element.ident;
|
||||
let ty = &element.ty;
|
||||
let attrs = &element.attrs;
|
||||
let attrs = cfg_attrs(&element.attrs);
|
||||
match element.kind {
|
||||
ElementKind::Required => quote! {
|
||||
#(#attrs)
|
||||
@@ -223,7 +242,7 @@ fn build_output(input: Input) -> TokenStream {
|
||||
.iter()
|
||||
.map(|element| {
|
||||
let ident = &element.ident;
|
||||
let attrs = &element.attrs;
|
||||
let attrs = cfg_attrs(&element.attrs);
|
||||
quote! {
|
||||
#(#attrs)
|
||||
*
|
||||
@@ -232,11 +251,11 @@ fn build_output(input: Input) -> TokenStream {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let from_tags_fields: Vec<proc_macro2::TokenStream>= input.elements.iter().map(|element| {
|
||||
let from_tags_fields: Vec<proc_macro2::TokenStream> = input.elements.iter().map(|element| {
|
||||
let ident = &element.ident;
|
||||
let ty = &element.ty;
|
||||
let tag_name = &element.name;
|
||||
let attrs = &element.attrs;
|
||||
let attrs = cfg_attrs(&element.attrs);
|
||||
|
||||
let try_convert = quote! {
|
||||
let value: ::std::result::Result<#ty, #root::tags::ParseTagsError> = <#ty as #root::tags::TagValue<#ty>>::from_raw_tag(value)
|
||||
|
||||
Reference in New Issue
Block a user