MessageAttributes

Struct MessageAttributes 

Source
pub struct MessageAttributes {
    pub action: Option<String>,
    pub from: Option<String>,
    pub method: Option<String>,
    pub status_callback: Option<String>,
    pub to: Option<String>,
}
Expand description

Attributes to pass to message

Fields§

§action: Option<String>

action - A URL specifying where Twilio should send status callbacks for the created outbound message.

§from: Option<String>

from - Phone Number to send Message from

§method: Option<String>

method - Action URL Method

§status_callback: Option<String>

statusCallback - Status callback URL. Deprecated in favor of action.

§to: Option<String>

to - Phone Number to send Message to

Implementations§

Source§

impl MessageAttributes

Source

pub fn new() -> Self

Create a new MessageAttributes

Examples found in repository?
examples/sms_message.rs (line 48)
46fn sms_with_attributes() {
47    let response = MessagingResponse::new().message_with_attributes(
48        MessageAttributes::new()
49            .to("+15551234567")
50            .from("+15559876543")
51            .action("https://example.com/message-status")
52            .method("POST")
53            .status_callback("https://example.com/status"),
54        "Your order #12345 has been shipped!",
55    );
56
57    println!("{}", response.to_xml());
58}
59
60/// MMS with a single media attachment
61fn mms_single_media() {
62    let message = Message::with_nouns(MessageAttributes::new())
63        .body(Body::new("Check out this image!"))
64        .add_media(Media::new("https://example.com/image.jpg"));
65
66    let response = MessagingResponse::new().message_with_nouns(message);
67
68    println!("{}", response.to_xml());
69}
70
71/// MMS with multiple media attachments
72fn mms_multiple_media() {
73    let message = Message::with_nouns(
74        MessageAttributes::new()
75            .to("+15551234567")
76            .from("+15559876543"),
77    )
78    .body(Body::new("Here are the photos from today's event!"))
79    .add_media(Media::new("https://example.com/photo1.jpg"))
80    .add_media(Media::new("https://example.com/photo2.jpg"))
81    .add_media(Media::new("https://example.com/photo3.jpg"));
82
83    let response = MessagingResponse::new().message_with_nouns(message);
84
85    println!("{}", response.to_xml());
86}
Source

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

Set the action URL

Examples found in repository?
examples/sms_message.rs (line 51)
46fn sms_with_attributes() {
47    let response = MessagingResponse::new().message_with_attributes(
48        MessageAttributes::new()
49            .to("+15551234567")
50            .from("+15559876543")
51            .action("https://example.com/message-status")
52            .method("POST")
53            .status_callback("https://example.com/status"),
54        "Your order #12345 has been shipped!",
55    );
56
57    println!("{}", response.to_xml());
58}
Source

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

Set the from phone number

Examples found in repository?
examples/sms_message.rs (line 50)
46fn sms_with_attributes() {
47    let response = MessagingResponse::new().message_with_attributes(
48        MessageAttributes::new()
49            .to("+15551234567")
50            .from("+15559876543")
51            .action("https://example.com/message-status")
52            .method("POST")
53            .status_callback("https://example.com/status"),
54        "Your order #12345 has been shipped!",
55    );
56
57    println!("{}", response.to_xml());
58}
59
60/// MMS with a single media attachment
61fn mms_single_media() {
62    let message = Message::with_nouns(MessageAttributes::new())
63        .body(Body::new("Check out this image!"))
64        .add_media(Media::new("https://example.com/image.jpg"));
65
66    let response = MessagingResponse::new().message_with_nouns(message);
67
68    println!("{}", response.to_xml());
69}
70
71/// MMS with multiple media attachments
72fn mms_multiple_media() {
73    let message = Message::with_nouns(
74        MessageAttributes::new()
75            .to("+15551234567")
76            .from("+15559876543"),
77    )
78    .body(Body::new("Here are the photos from today's event!"))
79    .add_media(Media::new("https://example.com/photo1.jpg"))
80    .add_media(Media::new("https://example.com/photo2.jpg"))
81    .add_media(Media::new("https://example.com/photo3.jpg"));
82
83    let response = MessagingResponse::new().message_with_nouns(message);
84
85    println!("{}", response.to_xml());
86}
Source

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

Set the HTTP method

Examples found in repository?
examples/sms_message.rs (line 52)
46fn sms_with_attributes() {
47    let response = MessagingResponse::new().message_with_attributes(
48        MessageAttributes::new()
49            .to("+15551234567")
50            .from("+15559876543")
51            .action("https://example.com/message-status")
52            .method("POST")
53            .status_callback("https://example.com/status"),
54        "Your order #12345 has been shipped!",
55    );
56
57    println!("{}", response.to_xml());
58}
Source

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

Set the status callback URL

Examples found in repository?
examples/sms_message.rs (line 53)
46fn sms_with_attributes() {
47    let response = MessagingResponse::new().message_with_attributes(
48        MessageAttributes::new()
49            .to("+15551234567")
50            .from("+15559876543")
51            .action("https://example.com/message-status")
52            .method("POST")
53            .status_callback("https://example.com/status"),
54        "Your order #12345 has been shipped!",
55    );
56
57    println!("{}", response.to_xml());
58}
Source

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

Set the to phone number

Examples found in repository?
examples/sms_message.rs (line 49)
46fn sms_with_attributes() {
47    let response = MessagingResponse::new().message_with_attributes(
48        MessageAttributes::new()
49            .to("+15551234567")
50            .from("+15559876543")
51            .action("https://example.com/message-status")
52            .method("POST")
53            .status_callback("https://example.com/status"),
54        "Your order #12345 has been shipped!",
55    );
56
57    println!("{}", response.to_xml());
58}
59
60/// MMS with a single media attachment
61fn mms_single_media() {
62    let message = Message::with_nouns(MessageAttributes::new())
63        .body(Body::new("Check out this image!"))
64        .add_media(Media::new("https://example.com/image.jpg"));
65
66    let response = MessagingResponse::new().message_with_nouns(message);
67
68    println!("{}", response.to_xml());
69}
70
71/// MMS with multiple media attachments
72fn mms_multiple_media() {
73    let message = Message::with_nouns(
74        MessageAttributes::new()
75            .to("+15551234567")
76            .from("+15559876543"),
77    )
78    .body(Body::new("Here are the photos from today's event!"))
79    .add_media(Media::new("https://example.com/photo1.jpg"))
80    .add_media(Media::new("https://example.com/photo2.jpg"))
81    .add_media(Media::new("https://example.com/photo3.jpg"));
82
83    let response = MessagingResponse::new().message_with_nouns(message);
84
85    println!("{}", response.to_xml());
86}

Trait Implementations§

Source§

impl Clone for MessageAttributes

Source§

fn clone(&self) -> MessageAttributes

Returns a duplicate 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 MessageAttributes

Source§

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

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

impl Default for MessageAttributes

Source§

fn default() -> MessageAttributes

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