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
infolevel or above in a production environment, while retainingdebuglevel 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§
Source§impl 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§
Source§impl Clone for FlashMessage
impl Clone for FlashMessage
Source§fn clone(&self) -> FlashMessage
fn clone(&self) -> FlashMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more