Struct actix_web_flash_messages::FlashMessage
source · [−]pub struct FlashMessage { /* private fields */ }
Expand description
A one-time user notification.
Flash messages are made of a Level
and a string of content.
The message level can be used for filtering and rendering - for example:
- Only show flash messages at
info
level or above in a production environment, while retainingdebug
level messages for local development; - Use different colours, in the UI, to display messages (e.g. red for errors, orange for warnings, etc.);
You can build a flash message via FlashMessage::new
by specifying its content and Level
.
You can also use the shorter level-based constructors - e.g. FlashMessage::info
.
Implementations
sourceimpl FlashMessage
impl FlashMessage
sourcepub fn new(content: String, level: Level) -> Self
pub fn new(content: String, level: Level) -> Self
Build a FlashMessage
by specifying its content and Level
.
sourcepub fn info<S: Into<String>>(content: S) -> Self
pub fn info<S: Into<String>>(content: S) -> Self
Build an info-level FlashMessage
by specifying its content.
sourcepub fn debug<S: Into<String>>(content: S) -> Self
pub fn debug<S: Into<String>>(content: S) -> Self
Build a debug-level FlashMessage
by specifying its content.
sourcepub fn success<S: Into<String>>(content: S) -> Self
pub fn success<S: Into<String>>(content: S) -> Self
Build a success-level FlashMessage
by specifying its content.
sourcepub fn warning<S: Into<String>>(content: S) -> Self
pub fn warning<S: Into<String>>(content: S) -> Self
Build a warning-level FlashMessage
by specifying its content.
sourcepub fn error<S: Into<String>>(content: S) -> Self
pub fn error<S: Into<String>>(content: S) -> Self
Build an error-level FlashMessage
by specifying its content.
sourcepub fn send(self)
pub fn send(self)
Attach this FlashMessage
to the outgoing request.
The message will be dropped if its Level
is below the minimum level
specified when configuring FlashMessagesFramework
via FlashMessagesFrameworkBuilder::minimum_level
.
This method will panic if FlashMessagesFramework
has not been registered as a middleware.
Trait Implementations
sourceimpl Clone for FlashMessage
impl Clone for FlashMessage
sourcefn clone(&self) -> FlashMessage
fn clone(&self) -> FlashMessage
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'de> Deserialize<'de> for FlashMessage
impl<'de> Deserialize<'de> for FlashMessage
sourcefn 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
sourceimpl Serialize for FlashMessage
impl Serialize for FlashMessage
Auto Trait Implementations
impl RefUnwindSafe for FlashMessage
impl Send for FlashMessage
impl Sync for FlashMessage
impl Unpin for FlashMessage
impl UnwindSafe for FlashMessage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more