pub struct Sender { /* private fields */ }Expand description
Used to send a V3 message body.
Implementations§
Source§impl Sender
impl Sender
Sourcepub fn new(api_key: String, client: Option<Client>) -> Sender
pub fn new(api_key: String, client: Option<Client>) -> Sender
Construct a new V3 message sender. The client parameter is optional and None uses the
default. If you provide your own configured Client, you must call Sender::get_headers and
set the returned value as default headers.
use reqwest::Client;
use sendgrid::SendgridResult;
use sendgrid::v3::Sender;
fn main() -> SendgridResult<()> {
// Below is an example of providing your own custom client.
let client = Client::builder()
.default_headers(Sender::get_headers("API_KEY".into())?)
.build()?;
Ok(())
}Sourcepub fn set_host<S: Into<String>>(&mut self, host: S)
pub fn set_host<S: Into<String>>(&mut self, host: S)
Sets the host to use for the API. This is useful if you are using a proxy or a local development server. It should be a full URL, including the protocol.
Sourcepub fn get_headers(api_key: &str) -> Result<HeaderMap, InvalidHeaderValue>
pub fn get_headers(api_key: &str) -> Result<HeaderMap, InvalidHeaderValue>
Configure the necessary headers to send an API request.
Sourcepub async fn send(&self, mail: &Message) -> SendgridResult<Response>
pub async fn send(&self, mail: &Message) -> SendgridResult<Response>
Send a V3 message and return the HTTP response or an error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sender
impl !RefUnwindSafe for Sender
impl Send for Sender
impl Sync for Sender
impl Unpin for Sender
impl !UnwindSafe for Sender
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