Struct SendGridMessage

Source
pub struct SendGridMessage {
Show 17 fields pub from: Option<EmailAddress>, pub subject: Option<String>, pub personalizations: Vec<Personalization>, pub contents: Vec<Content>, pub attachments: Vec<Attachment>, pub template_id: Option<String>, pub headers: HashMap<String, String>, pub sections: HashMap<String, String>, pub categories: Vec<String>, pub custom_args: HashMap<String, String>, pub send_at: Option<i64>, pub unsubscribe_group: Option<UnsubscribeGroup>, pub batch_id: Option<String>, pub ip_pool_name: Option<String>, pub mail_settings: Option<MailSettings>, pub tracking_settings: Option<TrackingSettings>, pub reply_to: Option<EmailAddress>,
}
Expand description

Represents the SendGrid email message output binding.

The following binding attributes are supported:

NameDescription
api_keyThe name of an app setting that contains your API key. If not set, the default app setting name is “AzureWebJobsSendGridApiKey”.
toThe default recipient’s email address.
fromThe default sender’s email address.
subjectThe default subject of the email.
textThe default email text content.

§Examples

use azure_functions::{
    bindings::{HttpRequest, HttpResponse, SendGridMessage},
    func,
};

#[func]
#[binding(name = "output1", from = "azure.functions.for.rust@example.com")]
pub fn send_email(req: HttpRequest) -> (HttpResponse, SendGridMessage) {
    let params = req.query_params();

    (
        "The email was sent.".into(),
        SendGridMessage::build()
            .to(params.get("to").unwrap().as_str())
            .subject(params.get("subject").unwrap().as_str())
            .content(params.get("content").unwrap().as_str())
            .finish(),
    )
}

Fields§

§from: Option<EmailAddress>

The email address of the sender. If None, the from binding attribute is used.

§subject: Option<String>

The subject of the email message. If None, the subject binding attribute is used.

§personalizations: Vec<Personalization>

The list of personalized messages and their metadata.

§contents: Vec<Content>

The list of email content.

§attachments: Vec<Attachment>

The list of email attachments.

§template_id: Option<String>

The id of the SendGrid template to use.

§headers: HashMap<String, String>

The map of key-value pairs of header names and the value to substitute for them.

§sections: HashMap<String, String>

The map of key-value pairs that define large blocks of content that can be inserted into your emails using substitution tags.

§categories: Vec<String>

The list of category names for this message.

§custom_args: HashMap<String, String>

The map of key-value pairs that are specific to the entire send that will be carried along with the email and its activity data.

§send_at: Option<i64>

The unix timestamp that specifies when the email should be sent from SendGrid.

§unsubscribe_group: Option<UnsubscribeGroup>

The associated unsubscribe group that specifies how to handle unsubscribes.

§batch_id: Option<String>

The id that represents a batch of emails to be associated to each other for scheduling.

§ip_pool_name: Option<String>

The IP pool that the message should be sent from.

§mail_settings: Option<MailSettings>

The settings that specify how the email message should be handled.

§tracking_settings: Option<TrackingSettings>

The settings that specify how the email message should be tracked.

§reply_to: Option<EmailAddress>

The email address and name of the individual who should receive responses to the email message.

Implementations§

Source§

impl SendGridMessage

Source

pub fn build() -> MessageBuilder

Creates a new MessageBuilder for building a SendGrid message.

§Examples
use azure_functions::bindings::SendGridMessage;

let message = SendGridMessage::build()
    .to("foo@example.com")
    .subject("The subject of the message")
    .content("I hope this message finds you well.")
    .finish();

assert_eq!(message.personalizations[0].to[0].email, "foo@example.com");
assert_eq!(message.personalizations[0].subject, Some("The subject of the message".to_owned()));
assert_eq!(message.contents[0].value, "I hope this message finds you well.");

Trait Implementations§

Source§

impl Clone for SendGridMessage

Source§

fn clone(&self) -> SendGridMessage

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SendGridMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SendGridMessage

Source§

fn default() -> SendGridMessage

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SendGridMessage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SendGridMessage

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,