Skip to main content

ToastCard

Struct ToastCard 

pub struct ToastCard<'a> {
Show 26 fields pub title: &'a str, pub body: &'a str, pub caption: &'a str, pub time: &'a str, pub reply: bool, pub reply_text: &'a str, pub reply_focused: bool, pub reply_hovered: bool, pub kind: ToastKind, pub icon: Option<Icon>, pub person: Option<(&'a str, &'a str)>, pub app_image: Option<&'a AppImage>, pub alpha: f32, pub closable: bool, pub close_hovered: bool, pub close_pressed: bool, pub actionable: bool, pub secondary_action: &'a str, pub secondary_action_icon: Option<Icon>, pub secondary_action_hovered: bool, pub secondary_action_pressed: bool, pub primary_action: &'a str, pub primary_action_icon: Option<Icon>, pub primary_action_hovered: bool, pub primary_action_pressed: bool, pub progress: Option<f32>,
}
Expand description

Immediate-mode content for one notification / toast card, painted by paint_card. Built fluently: ToastCard::new("Slow network", ToastKind::Warning).body("retrying").

Fields§

§title: &'a str

Primary line — the summary. Semibold, text_primary.

§body: &'a str

Optional secondary line (dim). Empty = single-line card.

§caption: &'a str

Optional attribution caption above the title (e.g. the sending app’s name), a dim Caption in sentence case. Empty = no caption.

§time: &'a str

How long ago it arrived (“2 m ago”), on the attribution line at the trailing edge, a dim Caption level with the caption. Empty = no time.

§reply: bool

Offer an inline reply field under the text (the sender takes one, inline-reply).

§reply_text: &'a str

What the person typed so far in the reply field.

§reply_focused: bool

Whether the reply field has the keyboard.

§reply_hovered: bool

Hover state for the reply field.

§kind: ToastKind

Severity — drives the leading icon and its colour.

§icon: Option<Icon>

What plain information leads with instead of a severity glyph, which only warnings, errors and successes carry: a glyph naming what the card is about…

§person: Option<(&'a str, &'a str)>

The person the card is from, as (name, identity): their avatar leads the card, in their presence colour, ahead of any glyph. Plain information with neither a person nor an icon leads with its text.

§app_image: Option<&'a AppImage>

The sending application’s own artwork, where a glyph cannot name it. A person’s avatar leads ahead of it; a severity glyph wins over it, so an alert never loses its state colour.

§alpha: f32

Enter/exit animation opacity in [0, 1]; 1.0 for a settled card.

§closable: bool

Draw a dismiss (X) button at the top-right and hand its rect back via ToastCardHit so the caller keeps one hit-test on widget-owned geometry.

§close_hovered: bool

Hover state for the dismiss button, when the caller tracks the cursor.

§close_pressed: bool

Whether the shared pointer controller has armed this control.

§actionable: bool

Draw an “actionable” chevron at the trailing edge (the card carries activatable actions).

§secondary_action: &'a str

Optional left/secondary and right/primary actions. These use the same immediate-mode Button painter as ordinary retained controls, so a notification can ask for a decision without inventing a second button language. Empty labels omit the action row entirely.

§secondary_action_icon: Option<Icon>§secondary_action_hovered: bool§secondary_action_pressed: bool

Whether the shared pointer controller has armed this control.

§primary_action: &'a str§primary_action_icon: Option<Icon>§primary_action_hovered: bool§primary_action_pressed: bool

Whether the shared pointer controller has armed this control.

§progress: Option<f32>

How far the work the card follows is, 0..=1: a determinate bar under the text. None draws none.

Implementations§

§

impl<'a> ToastCard<'a>

pub fn new(title: &'a str, kind: ToastKind) -> ToastCard<'a>

pub fn body(self, body: &'a str) -> ToastCard<'a>

pub fn progress(self, progress: f32) -> ToastCard<'a>

Follow work progress (0..=1) done with a determinate bar.

pub fn icon(self, icon: Option<Icon>) -> ToastCard<'a>

Lead plain information with icon (see Self::icon).

pub fn person(self, name: &'a str, identity: &'a str) -> ToastCard<'a>

Lead the card with the avatar of the person it is from.

pub fn app_image(self, image: Option<&'a AppImage>) -> ToastCard<'a>

Lead plain information with the sending application’s artwork.

pub fn caption(self, caption: &'a str) -> ToastCard<'a>

pub fn time(self, time: &'a str) -> ToastCard<'a>

How long ago it arrived, at the attribution line’s trailing edge.

pub fn reply(self, text: &'a str, focused: bool) -> ToastCard<'a>

Offer an inline reply field under the text, holding text so far.

pub fn alpha(self, alpha: f32) -> ToastCard<'a>

pub fn closable(self, v: bool) -> ToastCard<'a>

pub fn close_hovered(self, v: bool) -> ToastCard<'a>

pub fn actionable(self, v: bool) -> ToastCard<'a>

pub fn action(self, label: &'a str, hovered: bool) -> ToastCard<'a>

One action, at the card’s trailing edge beside its text (“Undo”, “Open”).

pub fn actions( self, secondary: &'a str, secondary_icon: Icon, secondary_hovered: bool, primary: &'a str, primary_icon: Icon, primary_hovered: bool, ) -> ToastCard<'a>

Add a standard two-choice action row. The secondary action is painted neutral on the left; the primary action is painted with the theme’s primary face on the right.

Trait Implementations§

§

impl<'a> Clone for ToastCard<'a>

§

fn clone(&self) -> ToastCard<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<'a> Copy for ToastCard<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ToastCard<'a>

§

impl<'a> !RefUnwindSafe for ToastCard<'a>

§

impl<'a> Send for ToastCard<'a>

§

impl<'a> Sync for ToastCard<'a>

§

impl<'a> Unpin for ToastCard<'a>

§

impl<'a> UnsafeUnpin for ToastCard<'a>

§

impl<'a> !UnwindSafe for ToastCard<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,