pub struct OwnedSendRequest {
pub to: String,
pub from: String,
pub text: String,
}Expand description
An owned variant of SendRequest for use in async contexts.
Holding &str references across .await points requires the referent to
outlive the future, which creates lifetime friction when the strings come
from String values. OwnedSendRequest sidesteps this by owning the
data and offering as_ref to borrow a
SendRequest<'_> at the call site.
§Examples
use sms_core::OwnedSendRequest;
let req = OwnedSendRequest::new("+14155551234", "+10005551234", "Hello!");
assert_eq!(req.to, "+14155551234");
// Borrow as a SendRequest<'_> for SmsClient::send()
let borrowed = req.as_ref();
assert_eq!(borrowed.to, req.to);Fields§
§to: StringE.164 destination phone number.
from: StringE.164 sender number or alphanumeric sender ID.
text: StringThe message body (plain text).
Implementations§
Source§impl OwnedSendRequest
impl OwnedSendRequest
Sourcepub fn new(
to: impl Into<String>,
from: impl Into<String>,
text: impl Into<String>,
) -> Self
pub fn new( to: impl Into<String>, from: impl Into<String>, text: impl Into<String>, ) -> Self
Create a new owned send request.
All three parameters accept anything that converts to String,
so both &str and String work without explicit .to_string() calls.
Sourcepub fn as_ref(&self) -> SendRequest<'_>
pub fn as_ref(&self) -> SendRequest<'_>
Borrow this owned request as a SendRequest suitable for
SmsClient::send.
Trait Implementations§
Source§impl Clone for OwnedSendRequest
impl Clone for OwnedSendRequest
Source§fn clone(&self) -> OwnedSendRequest
fn clone(&self) -> OwnedSendRequest
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 OwnedSendRequest
impl Debug for OwnedSendRequest
Source§impl<'de> Deserialize<'de> for OwnedSendRequest
impl<'de> Deserialize<'de> for OwnedSendRequest
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
Source§impl<'a> From<&'a OwnedSendRequest> for SendRequest<'a>
impl<'a> From<&'a OwnedSendRequest> for SendRequest<'a>
Source§fn from(req: &'a OwnedSendRequest) -> Self
fn from(req: &'a OwnedSendRequest) -> Self
Converts to this type from the input type.
Source§impl<'a> From<SendRequest<'a>> for OwnedSendRequest
impl<'a> From<SendRequest<'a>> for OwnedSendRequest
Source§fn from(req: SendRequest<'a>) -> Self
fn from(req: SendRequest<'a>) -> Self
Converts to this type from the input type.
Source§impl PartialEq for OwnedSendRequest
impl PartialEq for OwnedSendRequest
Source§impl Serialize for OwnedSendRequest
impl Serialize for OwnedSendRequest
impl Eq for OwnedSendRequest
impl StructuralPartialEq for OwnedSendRequest
Auto Trait Implementations§
impl Freeze for OwnedSendRequest
impl RefUnwindSafe for OwnedSendRequest
impl Send for OwnedSendRequest
impl Sync for OwnedSendRequest
impl Unpin for OwnedSendRequest
impl UnsafeUnpin for OwnedSendRequest
impl UnwindSafe for OwnedSendRequest
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