Struct PersonalizationBuilder

Source
pub struct PersonalizationBuilder { /* private fields */ }
Expand description

Builder pattern for Personalization. Make sure you call build() when done to consume this and return the underlying Personalization. Use default() to construct.

Implementations§

Source§

impl PersonalizationBuilder

Source

pub fn to(self, contact: Contact) -> Self

Add a To contact. Use ContactBuilder to construct this.

§Examples

let builder = PersonalizationBuilder::default()
              .to(ContactBuilder::new("to@example.com").build());
Source

pub fn cc(self, contact: Contact) -> Self

Add a CC contact. Use ContactBuilder to construct this.

§Examples

let builder = PersonalizationBuilder::default()
              .cc(ContactBuilder::new("cc@example.com").build());
Source

pub fn bcc(self, contact: Contact) -> Self

Add a BCC contact. Use ContactBuilder to construct this.

§Examples

let builder = PersonalizationBuilder::default()
              .bcc(ContactBuilder::new("bcc@example.com").build());
Source

pub fn subject(self, subject: impl Into<String>) -> Self

Set a custom subject line.

§Examples

let builder = PersonalizationBuilder::default()
              .subject("Subject line");
Source

pub fn header<S: Into<String>>(self, key: S, value: S) -> Self

Set an email header.

§Parameters

key: impl Into value: impl Into

§Examples

let builder = PersonalizationBuilder::default()
              .header("Key", "Value");
Source

pub fn headers(self, data: HashMap<String, String>) -> Self

Assign multiple email headers

§Parameters

data: HashMap<String, String>

§Examples

let headers: HashMap<String, String> = HashMap::new();
let builder = PersonalizationBuilder::default()
.headers(headers);
Source

pub fn substitution<S: Into<String>>(self, key: S, value: S) -> Self

Set a substitution

§Parameters

key: impl Into value: impl Into

§Examples

let builder = PersonalizationBuilder::default()
              .substitution("Key", "Value");
Source

pub fn dynamic_template_datum<S: Into<String>>(self, key: S, value: S) -> Self

Add a single dynamic template substitution

§Parameters

key: impl Into value: impl Into

§Examples

let builder = PersonalizationBuilder::default()
              .dynamic_template_datum("Key", "Value");
Source

pub fn dynamic_template_data(self, data: HashMap<String, String>) -> Self

Assign multiple dynamic template substitutions, overwriting all synamic template substitutions with supplied data

§Parameters

data: HashMap<String, String>

§Examples

let substitutions: HashMap<String, String> = HashMap::new();
let builder = PersonalizationBuilder::default()
              .dynamic_template_data(substitutions);
Source

pub fn custom_arg<S: Into<String>>(self, key: S, value: S) -> Self

Set a custom_arg

§Parameters

key: impl Into value: impl Into

§Examples

let builder = PersonalizationBuilder::default()
              .custom_arg("Key", "Value");
Source

pub fn send_at(self, time: i32) -> Self

Set a send_at time in seconds

§Examples

let builder = PersonalizationBuilder::default()
              .send_at(3600);
Source

pub fn build(self) -> Personalization

Consume the builder and return the underlying ‘Personalization’

§Examples

let builder = PersonalizationBuilder::default()
              .build();

Trait Implementations§

Source§

impl Default for PersonalizationBuilder

Source§

fn default() -> PersonalizationBuilder

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.