pub struct NotificationTexts { /* private fields */ }Expand description
The active notification templates of one type with its data, ready to render a text per channel and language. Load it before sending a Laravel notification, keep it in the notification, and render in its channel methods, which can’t wait for the database:
let texts = laravel_template_engine::notification(&shipped).await?;
let sms = texts.text("sms", Some("uk"))?;Implementations§
Source§impl NotificationTexts
impl NotificationTexts
Sourcepub fn render(
&self,
channel: &str,
locale: Option<&str>,
) -> Result<Option<RenderedText>>
pub fn render( &self, channel: &str, locale: Option<&str>, ) -> Result<Option<RenderedText>>
The text for channel in locale, or the closest language the template has; None
when no active template writes for the channel.
§Errors
Fails when the template doesn’t render.
Sourcepub fn text(&self, channel: &str, locale: Option<&str>) -> Result<String>
pub fn text(&self, channel: &str, locale: Option<&str>) -> Result<String>
The text for channel in locale, for a notification’s channel method.
§Errors
Fails with TemplateError::NoNotification when no active template writes for the
channel, which aborts the notification, or when the template doesn’t render.
Trait Implementations§
Source§impl Clone for NotificationTexts
impl Clone for NotificationTexts
Auto Trait Implementations§
impl !RefUnwindSafe for NotificationTexts
impl !UnwindSafe for NotificationTexts
impl Forget for NotificationTexts
impl Freeze for NotificationTextswhere
&'static str: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
PhantomData<Template>: Freeze,
*const ArcInner<Vec<Filter>> is !null: Freeze,
PhantomData<ArcInner<Vec<Filter>>>: Freeze,
*const ArcInner<Vec<Image>> is !null: Freeze,
PhantomData<ArcInner<Vec<Image>>>: Freeze,
*const ArcInner<Vec<Font>> is !null: Freeze,
PhantomData<ArcInner<Vec<Font>>>: Freeze,
*const ArcInner<Vec<Layout>> is !null: Freeze,
PhantomData<ArcInner<Vec<Layout>>>: Freeze,
*const ArcInner<Vec<Channel>> is !null: Freeze,
PhantomData<ArcInner<Vec<Channel>>>: Freeze,
impl Move for NotificationTexts
impl Send for NotificationTexts
impl Sync for NotificationTexts
impl Unpin for NotificationTexts
impl UnsafeUnpin for NotificationTextswhere
&'static str: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
PhantomData<Template>: UnsafeUnpin,
*const ArcInner<Vec<Filter>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<Filter>>>: UnsafeUnpin,
*const ArcInner<Vec<Image>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<Image>>>: UnsafeUnpin,
*const ArcInner<Vec<Font>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<Font>>>: UnsafeUnpin,
*const ArcInner<Vec<Layout>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<Layout>>>: UnsafeUnpin,
*const ArcInner<Vec<Channel>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<Channel>>>: UnsafeUnpin,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more