Skip to main content

Notice

Struct Notice 

Source
pub struct Notice<M> { /* private fields */ }
Expand description

A notification to show on screen, from Widget::notices.

It says what the notification is, not how it looks: the host lays out the notification, places it and animates it in and out. Its key is how the host tells notices apart from one view to the next: a notice that keeps its key and changes its text is updated in place, and one whose key is gone from the list leaves the screen.

Implementations§

Source§

impl<M> Notice<M>

Source

pub fn new(key: u64, summary: impl Into<String>) -> Self

Source

pub fn app(self, name: impl Into<String>) -> Self

The name of the app it comes from.

Source

pub fn app_icon(self, app_id: impl Into<String>) -> Self

The app’s icon, by app id, like app_icon, or a file:// URL to a picture of it.

Source

pub fn icon(self, icon: Icon) -> Self

A symbol as its icon, drawn in the text’s tone, for what’s about the device rather than an app: a battery running low, a network that dropped. It wins over app_icon.

Source

pub fn image(self, url: impl Into<String>) -> Self

A picture of its own, by URL, like a cover: an avatar, a screenshot. The host shows it beside the text, or under it, full width, if it’s wide.

Source

pub fn pixels(self, pixels: Pixels) -> Self

A picture of its own, as its pixels: what an app sent as bytes rather than a file. It wins over image.

Source

pub fn time(self, time: SystemTime) -> Self

When it arrived. The host says how long ago, beside where it’s from.

Source

pub fn thread(self, key: impl Into<String>) -> Self

The conversation it’s part of: a chat, a session. The host stacks notices of the same app and thread that come one after another into one, the newest in full.

Source

pub fn thread_name(self, name: impl Into<String>) -> Self

What to call its thread, beside the app’s name: the chat, the session.

Source

pub fn progress(self, fraction: f32) -> Self

How far along what it’s about is, from 0.0 to 1.0: a download, a copy.

Source

pub fn choices(self, choices: Choices<M>) -> Self

Options to pick from (Choices), above the reply field and the actions.

Source

pub fn step(self, index: usize, count: usize, on_back: Option<M>) -> Self

It’s question index (from 0) of count, asked one at a time on the same notice. The host shows where it is, and slides the content along when index changes. on_back goes to the one before.

Source

pub fn body(self, text: impl Into<String>) -> Self

Plain text under the summary. The host wraps it and cuts it off after a few lines.

Source

pub fn markdown(self) -> Self

The body is Markdown, like a markdown node.

Source

pub fn urgency(self, urgency: Urgency) -> Self

Source

pub fn action(self, label: impl Into<String>, message: M) -> Self

A button on the notification that sends message. The first one is the main action.

Source

pub fn on_press(self, message: M) -> Self

Sent on a click on the notification itself, outside its buttons.

Source

pub fn on_dismiss(self, message: M) -> Self

Sent when its close button is clicked. Without it, it has none.

Source

pub fn expires(self, after: Duration, message: M) -> Self

Sent once it has been on screen for after. The host doesn’t count while the pointer is on it or it’s waiting to be shown. Without it, it stays until it leaves the list.

Source

pub fn reply(self, reply: Reply<M>) -> Self

A field to type an answer into (Reply).

Source

pub fn map<N: 'static>( self, f: &(impl Fn(M) -> N + Clone + 'static), ) -> Notice<N>
where M: 'static,

Source

pub fn key(&self) -> u64

Auto Trait Implementations§

§

impl<M> !RefUnwindSafe for Notice<M>

§

impl<M> !Send for Notice<M>

§

impl<M> !Sync for Notice<M>

§

impl<M> !UnwindSafe for Notice<M>

§

impl<M> Freeze for Notice<M>
where Vec<(String, M)>: Freeze, Option<ChoicesParts<M>>: Freeze, Option<StepParts<M>>: Freeze, Option<M>: Freeze, Option<(Duration, M)>: Freeze, Option<Reply<M>>: Freeze,

§

impl<M> Unpin for Notice<M>
where Vec<(String, M)>: Unpin, Option<ChoicesParts<M>>: Unpin, Option<StepParts<M>>: Unpin, Option<M>: Unpin, Option<(Duration, M)>: Unpin, Option<Reply<M>>: Unpin,

§

impl<M> UnsafeUnpin for Notice<M>
where Vec<(String, M)>: UnsafeUnpin, Option<ChoicesParts<M>>: UnsafeUnpin, Option<StepParts<M>>: UnsafeUnpin, Option<M>: UnsafeUnpin, Option<(Duration, M)>: UnsafeUnpin, Option<Reply<M>>: UnsafeUnpin,

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
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.