[][src]Struct azure_functions::bindings::SignalRMessage

pub struct SignalRMessage {
    pub user_id: Option<String>,
    pub group_name: Option<String>,
    pub target: String,
    pub arguments: Vec<Value>,
}

Represents the SignalR message output binding.

The following binding attributes are supported:

NameDescription
nameThe name of the parameter being bound.
hub_nameThe name of the SignalR hub that will receive the message.
connectionThe name of the app setting that contains the SignalR Service connection string. Defaults to AzureSignalRConnectionString.

Examples

This example implements an HTTP-triggered Azure Function that returns a SignalRMessage binding:

use azure_functions::{
    bindings::{HttpRequest, SignalRMessage},
    func,
};
use serde_json::{to_value, Value};

#[func]
#[binding(name = "req", auth_level = "anonymous", methods = "post")]
#[binding(name = "$return", hub_name = "chat", connection = "myconnection")]
pub fn send_message(req: HttpRequest) -> SignalRMessage {
    SignalRMessage {
        user_id: req.query_params().get("user").map(|v| v.to_owned()),
        group_name: req.query_params().get("group").map(|v| v.to_owned()),
        target: "newMessage".to_owned(),
        arguments: vec![req.query_params().get("message").map_or(Value::Null, |v| to_value(v).unwrap())],
    }
}

Fields

user_id: Option<String>

The optional user id to send the message to.

group_name: Option<String>

The optional group name to send the message to.

target: String

The target method name to invoke on each SignalR client.

arguments: Vec<Value>

The arguments to pass to the target method.

Trait Implementations

impl Clone for SignalRMessage[src]

impl Debug for SignalRMessage[src]

impl Serialize for SignalRMessage[src]

impl<'de> Deserialize<'de> for SignalRMessage[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> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

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

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