[][src]Struct azure_functions::bindings::GenericInput

pub struct GenericInput {
    pub data: Value,
}

Represents a generic input binding.

The following binding attributes are supported:

NameDescription
typeThe binding type.
nameThe 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]

impl Debug for GenericInput[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> IntoRequest<T> for T[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,