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
impl MessageAttributes
Sourcepub fn new() -> Self
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}Sourcepub fn action(self, action: impl Into<String>) -> Self
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}Sourcepub fn from(self, from: impl Into<String>) -> Self
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}Sourcepub fn method(self, method: impl Into<String>) -> Self
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}Sourcepub fn status_callback(self, status_callback: impl Into<String>) -> Self
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}Sourcepub fn to(self, to: impl Into<String>) -> Self
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
impl Clone for MessageAttributes
Source§fn clone(&self) -> MessageAttributes
fn clone(&self) -> MessageAttributes
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MessageAttributes
impl Debug for MessageAttributes
Source§impl Default for MessageAttributes
impl Default for MessageAttributes
Source§fn default() -> MessageAttributes
fn default() -> MessageAttributes
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MessageAttributes
impl RefUnwindSafe for MessageAttributes
impl Send for MessageAttributes
impl Sync for MessageAttributes
impl Unpin for MessageAttributes
impl UnwindSafe for MessageAttributes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more