pub struct Recipient {
pub address: String,
pub name: Option<String>,
}
Expand description
Represents an email recipient with an email address and optional name.
Recipients are used in the EmailOptions
struct to specify who will
receive an email, including primary recipients, CC, and BCC.
§Examples
use send_with_us::types::Recipient;
let recipient = Recipient::new("user@example.com");
let recipient = Recipient::new("user@example.com")
.with_name("John Doe");
Fields§
§address: String
Recipient’s email address
name: Option<String>
Recipient’s name (optional)
Implementations§
Source§impl Recipient
impl Recipient
Sourcepub fn new(address: impl Into<String>) -> Self
pub fn new(address: impl Into<String>) -> Self
Creates a new recipient with the specified email address.
§Arguments
address
- The recipient’s email address
§Returns
A new Recipient instance with the provided email and no name
§Examples
use send_with_us::types::Recipient;
let recipient = Recipient::new("user@example.com");
assert_eq!(recipient.address, "user@example.com");
assert_eq!(recipient.name, None);
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Sets the recipient’s name.
This method uses the builder pattern, allowing for method chaining.
§Arguments
name
- The recipient’s name
§Returns
Self with the updated name for method chaining
§Examples
use send_with_us::types::Recipient;
let recipient = Recipient::new("user@example.com")
.with_name("John Doe");
assert_eq!(recipient.address, "user@example.com");
assert_eq!(recipient.name, Some("John Doe".to_string()));
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Recipient
impl<'de> Deserialize<'de> for Recipient
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Recipient
Auto Trait Implementations§
impl Freeze for Recipient
impl RefUnwindSafe for Recipient
impl Send for Recipient
impl Sync for Recipient
impl Unpin for Recipient
impl UnwindSafe for Recipient
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