[][src]Struct azure_functions::bindings::EventHubMessage

pub struct EventHubMessage(_);

Represents an Event Hubs message output binding.

The following binding attributes are supported:

Name Description
name The name of the parameter being bound.
event_hub_name The name of the event hub. When the event hub name is also present in the connection string, that value overrides this property at runtime.
connection The name of an app setting that contains the connection string to the event hub's namespace. This connection string must have send permissions to send the message to the event stream.

Examples

Creating a message from a string:

use azure_functions::bindings::{HttpRequest, EventHubMessage};
use azure_functions::func;

#[func]
#[binding(name = "output1", connection = "connection", event_hub_name = "example")]
pub fn create_message(_req: HttpRequest) -> ((), EventHubMessage) {
    ((), "Hello world!".into())
}

Creating a message from a JSON value (see the json! macro from the serde_json crate):

use azure_functions::bindings::{HttpRequest, EventHubMessage};
use azure_functions::func;
use serde_json::json;

#[func]
#[binding(name = "output1", connection = "connection", event_hub_name = "example")]
pub fn create_message(_req: HttpRequest) -> ((), EventHubMessage) {
    (() ,json!({ "hello": "world!" }).into())
}

Creating a message from a sequence of bytes:

use azure_functions::bindings::{HttpRequest, EventHubMessage};
use azure_functions::func;

#[func]
#[binding(name = "output1", connection = "connection", event_hub_name = "example")]
pub fn create_message(_req: HttpRequest) -> ((), EventHubMessage) {
    ((), [1, 2, 3][..].into())
}

Methods

impl EventHubMessage[src]

pub fn as_str(&self) -> Option<&str>[src]

Gets the content of the message as a string.

Returns None if there is no valid string representation of the message.

pub fn as_bytes(&self) -> &[u8][src]

Gets the content of the message as a slice of bytes.

pub fn as_json<'b, T>(&'b self) -> Result<T> where
    T: Deserialize<'b>, 
[src]

Deserializes the message as JSON to the requested type.

Trait Implementations

impl Into<String> for EventHubMessage[src]

impl Into<Value> for EventHubMessage[src]

impl Into<Vec<u8>> for EventHubMessage[src]

impl<'a> Into<Body<'a>> for EventHubMessage[src]

impl Clone for EventHubMessage[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> From<&'a str> for EventHubMessage[src]

impl From<String> for EventHubMessage[src]

impl<'_> From<&'_ Value> for EventHubMessage[src]

impl From<Value> for EventHubMessage[src]

impl<'a> From<&'a [u8]> for EventHubMessage[src]

impl From<Vec<u8>> for EventHubMessage[src]

impl Debug for EventHubMessage[src]

impl Display for EventHubMessage[src]

Auto Trait Implementations

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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

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> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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

impl<T> Erased for T