Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Last two crates off nightly #131

Merged
merged 2 commits into from Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
448 changes: 212 additions & 236 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions README.md
Expand Up @@ -44,17 +44,6 @@ Documentation for the [latest published version](https://docs.rs/azure-functions

# Getting Started

## Nightly Rust Compiler

The Azure Functions for Rust SDK requires the use of a nightly Rust compiler due the use of the experimental Rust features.

Use [rustup](https://github.com/rust-lang-nursery/rustup.rs) to install a nightly compiler:

```
$ rustup install nightly
$ rustup default nightly
```

## Installing the Azure Functions for Rust SDK

Install the Azure Functions for Rust SDK using `cargo install`:
Expand Down
8 changes: 7 additions & 1 deletion azure-functions-codegen/Cargo.toml
Expand Up @@ -15,5 +15,11 @@ proc-macro = true
azure-functions-shared = { version = "0.3.0", path = "../azure-functions-shared" }
quote = "0.6.11"
syn = { version = "0.15.26", features = ["full"] }
proc-macro2 = { version = "0.4.27", features = ["nightly"] }
proc-macro2 = { version = "0.4.27" }
lazy_static = "1.2.0"
proc-macro-hack = "0.5.4"
peterhuene marked this conversation as resolved.
Show resolved Hide resolved
cfg-if = "0.1.6"


[features]
unstable = []
peterhuene marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions azure-functions-codegen/src/export.rs
@@ -1,6 +1,6 @@
use crate::util::PathVec;
use crate::util::{PathVec, TryFrom};
use proc_macro::TokenStream;
use std::convert::TryFrom;
use quote::quote;
use std::fmt::Write;
use syn::{parse_str, Expr};

Expand Down
8 changes: 3 additions & 5 deletions azure-functions-codegen/src/func/binding.rs
@@ -1,14 +1,12 @@
use crate::func::bindings::{
Blob, BlobTrigger, Http, HttpTrigger, Queue, QueueTrigger, Table, TimerTrigger,
};
use crate::util::AttributeArguments;
use crate::util::{AttributeArguments, MacroError, TryFrom};
use azure_functions_shared::codegen;
use proc_macro::Diagnostic;
use proc_macro2::TokenStream;
use quote::ToTokens;
use quote::{quote, ToTokens};
use std::borrow::Cow;
use std::collections::HashMap;
use std::convert::TryFrom;

pub struct Binding<'a>(pub &'a codegen::Binding);

Expand Down Expand Up @@ -52,7 +50,7 @@ impl ToTokens for Binding<'_> {
}
}

pub type BindingFactory = fn(AttributeArguments) -> Result<codegen::Binding, Diagnostic>;
pub type BindingFactory = fn(AttributeArguments) -> Result<codegen::Binding, MacroError>;
type BindingMap = HashMap<&'static str, BindingFactory>;

lazy_static! {
Expand Down
50 changes: 28 additions & 22 deletions azure-functions-codegen/src/func/bindings/blob.rs
@@ -1,18 +1,17 @@
use crate::util::{
to_camel_case, AttributeArguments, QuotableBorrowedStr, QuotableDirection, QuotableOption,
to_camel_case, AttributeArguments, MacroError, QuotableBorrowedStr, QuotableDirection,
QuotableOption, TryFrom,
};
use azure_functions_shared::codegen;
use proc_macro::Diagnostic;
use quote::ToTokens;
use quote::{quote, ToTokens};
use std::borrow::Cow;
use std::convert::TryFrom;
use syn::spanned::Spanned;
use syn::Lit;

pub struct Blob<'a>(pub Cow<'a, codegen::bindings::Blob>);

impl TryFrom<AttributeArguments> for Blob<'_> {
type Error = Diagnostic;
type Error = MacroError;

fn try_from(args: AttributeArguments) -> Result<Self, Self::Error> {
let mut name = None;
Expand All @@ -28,46 +27,53 @@ impl TryFrom<AttributeArguments> for Blob<'_> {
name = Some(Cow::Owned(to_camel_case(&s.value())));
}
_ => {
return Err(value
.span()
.unstable()
.error("expected a literal string value for the 'name' argument"));
return Err((
value.span(),
"expected a literal string value for the 'name' argument",
)
.into());
}
},
"path" => match value {
Lit::Str(s) => {
path = Some(Cow::Owned(s.value()));
}
_ => {
return Err(value
.span()
.unstable()
.error("expected a literal string value for the 'path' argument"));
return Err((
value.span(),
"expected a literal string value for the 'path' argument",
)
.into());
}
},
"connection" => match value {
Lit::Str(s) => {
connection = Some(Cow::Owned(s.value()));
}
_ => {
return Err(value.span().unstable().error(
return Err((
value.span(),
"expected a literal string value for the 'connection' argument",
));
)
.into());
}
},
_ => {
return Err(key.span().unstable().error(format!(
"unsupported binding attribute argument '{}'",
key_str
)));
return Err((
key.span(),
format!("unsupported binding attribute argument '{}'", key_str).as_ref(),
)
.into());
}
};
}

if path.is_none() {
return Err(args
.span
.error("the 'path' argument is required for blob bindings."));
return Err((
args.span,
"the 'path' argument is required for blob bindings.",
)
.into());
}

Ok(Blob(Cow::Owned(codegen::bindings::Blob {
Expand Down
50 changes: 28 additions & 22 deletions azure-functions-codegen/src/func/bindings/blob_trigger.rs
@@ -1,18 +1,17 @@
use crate::util::{
to_camel_case, AttributeArguments, QuotableBorrowedStr, QuotableDirection, QuotableOption,
to_camel_case, AttributeArguments, MacroError, QuotableBorrowedStr, QuotableDirection,
QuotableOption, TryFrom,
};
use azure_functions_shared::codegen;
use proc_macro::Diagnostic;
use quote::ToTokens;
use quote::{quote, ToTokens};
use std::borrow::Cow;
use std::convert::TryFrom;
use syn::spanned::Spanned;
use syn::Lit;

pub struct BlobTrigger<'a>(pub Cow<'a, codegen::bindings::BlobTrigger>);

impl TryFrom<AttributeArguments> for BlobTrigger<'_> {
type Error = Diagnostic;
type Error = MacroError;

fn try_from(args: AttributeArguments) -> Result<Self, Self::Error> {
let mut name = None;
Expand All @@ -28,46 +27,53 @@ impl TryFrom<AttributeArguments> for BlobTrigger<'_> {
name = Some(Cow::Owned(to_camel_case(&s.value())));
}
_ => {
return Err(value
.span()
.unstable()
.error("expected a literal string value for the 'name' argument"));
return Err((
value.span(),
"expected a literal string value for the 'name' argument",
)
.into());
}
},
"path" => match value {
Lit::Str(s) => {
path = Some(Cow::Owned(s.value()));
}
_ => {
return Err(value
.span()
.unstable()
.error("expected a literal string value for the 'path' argument"));
return Err((
value.span(),
"expected a literal string value for the 'path' argument",
)
.into());
}
},
"connection" => match value {
Lit::Str(s) => {
connection = Some(Cow::Owned(s.value()));
}
_ => {
return Err(value.span().unstable().error(
return Err((
value.span(),
"expected a literal string value for the 'connection' argument",
));
)
.into());
}
},
_ => {
return Err(key.span().unstable().error(format!(
"unsupported binding attribute argument '{}'",
key_str
)));
return Err((
key.span(),
format!("unsupported binding attribute argument '{}'", key_str).as_ref(),
)
.into());
}
};
}

if path.is_none() {
return Err(args
.span
.error("the 'path' argument is required for blob trigger bindings."));
return Err((
args.span,
"the 'path' argument is required for blob trigger bindings.",
)
.into());
}

Ok(BlobTrigger(Cow::Owned(codegen::bindings::BlobTrigger {
Expand Down
26 changes: 13 additions & 13 deletions azure-functions-codegen/src/func/bindings/http.rs
@@ -1,17 +1,15 @@
use crate::util::{to_camel_case, AttributeArguments, QuotableBorrowedStr};
use crate::util::{to_camel_case, AttributeArguments, MacroError, QuotableBorrowedStr, TryFrom};
use azure_functions_shared::codegen;
use proc_macro::Diagnostic;
use proc_macro2::TokenStream;
use quote::ToTokens;
use quote::{quote, ToTokens};
use std::borrow::Cow;
use std::convert::TryFrom;
use syn::spanned::Spanned;
use syn::Lit;

pub struct Http<'a>(pub Cow<'a, codegen::bindings::Http>);

impl TryFrom<AttributeArguments> for Http<'_> {
type Error = Diagnostic;
type Error = MacroError;

fn try_from(args: AttributeArguments) -> Result<Self, Self::Error> {
let mut name = None;
Expand All @@ -25,17 +23,19 @@ impl TryFrom<AttributeArguments> for Http<'_> {
name = Some(Cow::Owned(to_camel_case(&s.value())));
}
_ => {
return Err(value
.span()
.unstable()
.error("expected a literal string value for the 'name' argument"));
return Err((
value.span(),
"expected a literal string value for the 'name' argument",
)
.into());
}
},
_ => {
return Err(key
.span()
.unstable()
.error(format!("unsupported attribute argument '{}'", key_str)));
return Err((
key.span(),
format!("unsupported attribute argument '{}'", key_str).as_ref(),
)
.into());
}
};
}
Expand Down