Skip to main content

notice_lifetime

Function notice_lifetime 

Source
pub const fn notice_lifetime(persistence: Persistence) -> Option<Duration>
Expand description

How long a notice lives, given whether it goes away on its own.

makeover-layout documents Notice::Toast as “transient, stacked, dismisses itself”, and the description deliberately says nothing about when. This is when, on the renderer’s side of the line:

assert_eq!(
    notice_lifetime(Persistence::Transient),
    Some(Moment::Dismiss.duration())
);
assert_eq!(notice_lifetime(Persistence::Standing), None);

None is not “the caller decides”. It means the notice has no lifetime: a banner is dismissed by fixing the cause, and an error is a banner. See the crate header on why severity is not a fifth duration.