[−][src]Struct azure_functions::bindings::GenericInput
Represents a generic input binding.
The following binding attributes are supported:
Name | Description |
---|---|
type | The binding type. |
name | The name of the parameter being bound. |
* | The additional binding attributes specific to the binding type. Supported value types are strings, booleans, and integers. |
Examples
An example of using a GenericInput
binding instead of a CosmosDbDocument
binding:
use azure_functions::{ bindings::{GenericInput, HttpRequest, HttpResponse}, func, generic::Value, }; use serde_json::from_str; #[func] #[binding(name = "req", route = "read/{id}")] #[binding( type = "cosmosDB", name = "document", connectionStringSetting = "connection", databaseName = "exampledb", collectionName = "documents", id = "{id}", partitionKey = "{id}" )] pub fn read_document(req: HttpRequest, document: GenericInput) -> HttpResponse { match document.data { Value::String(s) => { let v: serde_json::Value = from_str(&s).expect("expected JSON data"); if v.is_null() { format!( "Document with id '{}' does not exist.", req.route_params().get("id").unwrap() ) .into() } else { v.into() } } _ => panic!("expected string for CosmosDB document data"), } }
Fields
data: Value
The input binding data.
Trait Implementations
impl<'a> Into<Body<'a>> for GenericInput
[src]
impl Clone for GenericInput
[src]
fn clone(&self) -> GenericInput
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for GenericInput
[src]
Auto Trait Implementations
impl Send for GenericInput
impl Sync for GenericInput
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,