pub struct TencentSmsNotifier { /* private fields */ }Expand description
腾讯云短信通知发送器 — 基于腾讯云短信 API(SendSms action)
通过 HttpTransport trait 抽象 HTTP 发送,业务方注入具体 HTTP 客户端即可使用。
真实签名由业务方在实现 HttpTransport 时注入(如通过 header 携带
Authorization、X-TC-Action 等),本实现仅构造请求 JSON body。
§用法
ⓘ
use sz_rust_core::notify::{
TencentSmsConfig, TencentSmsNotifier, MemoryHttpTransport, SmsMessage, SmsNotifier,
};
use std::sync::Arc;
let transport = Arc::new(MemoryHttpTransport::new());
let config = TencentSmsConfig::new("AKIDxxx", "SKxxx", "1400000000")
.with_default_sign_name("鲜视达科技");
let notifier = TencentSmsNotifier::new(config, transport);
let msg = SmsMessage::new()
.phone("+8613800138000")
.template_id("123456")
.template_param("1234");
notifier.send_sms(msg).unwrap();Implementations§
Source§impl TencentSmsNotifier
impl TencentSmsNotifier
Sourcepub fn new(config: TencentSmsConfig, transport: Arc<dyn HttpTransport>) -> Self
pub fn new(config: TencentSmsConfig, transport: Arc<dyn HttpTransport>) -> Self
Trait Implementations§
Source§impl SmsNotifier for TencentSmsNotifier
impl SmsNotifier for TencentSmsNotifier
Source§fn send_sms(&self, message: SmsMessage) -> Result<(), NotifyError>
fn send_sms(&self, message: SmsMessage) -> Result<(), NotifyError>
发送短信 Read more
Auto Trait Implementations§
impl !RefUnwindSafe for TencentSmsNotifier
impl !UnwindSafe for TencentSmsNotifier
impl Freeze for TencentSmsNotifier
impl Send for TencentSmsNotifier
impl Sync for TencentSmsNotifier
impl Unpin for TencentSmsNotifier
impl UnsafeUnpin for TencentSmsNotifier
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.