Skip to main content

Notice

Struct Notice 

Source
#[non_exhaustive]
pub struct Notice {
Show 14 fields pub v: u32, pub id: NoticeId, pub at_ms: u64, pub severity: Severity, pub kind: Kind, pub origin: Origin, pub headline: String, pub reason: Option<String>, pub hint: Option<String>, pub details: Option<String>, pub actions: Vec<NoticeAction>, pub subject: Option<String>, pub place: Option<String>, pub node: Option<String>,
}
Expand description

One message for people: see the module.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§v: u32

The version of its JSON shape (VERSION).

§id: NoticeId

Its id; empty until it is raised (the store gives one).

§at_ms: u64

When it happened, in milliseconds since 1970 (UTC); 0 until it is raised (raising it sets now).

§severity: Severity§kind: Kind§origin: Origin§headline: String

What happened, in the user’s words: “cloudy was not added”.

§reason: Option<String>

Why, in the user’s words, when known.

§hint: Option<String>

What the user can do about it.

§details: Option<String>

The technical chain (an error’s sources), copyable.

§actions: Vec<NoticeAction>

Its buttons, in order.

§subject: Option<String>

What it is about (a photo, a job, a node: node:cloudy).

§place: Option<String>

Where it happened in the interface (a window, a panel, a page: settings/storage/nodes).

§node: Option<String>

The node it happened on, for a notice from another node.

Implementations§

Source§

impl Notice

Source

pub fn new(severity: Severity, headline: impl Into<String>) -> Self

Source

pub fn info(headline: impl Into<String>) -> Self

Source

pub fn success(headline: impl Into<String>) -> Self

Source

pub fn warning(headline: impl Into<String>) -> Self

Source

pub fn error(headline: impl Into<String>) -> Self

Source

pub fn id(self, id: impl Into<NoticeId>) -> Self

Its id (by default the store gives one when it is raised).

Source

pub fn at_ms(self, at_ms: u64) -> Self

When it happened, in milliseconds since 1970 (by default, when it is raised).

Source

pub fn kind(self, kind: Kind) -> Self

Source

pub fn condition(self) -> Self

A condition: it lasts until it is resolved.

Source

pub fn ask(self) -> Self

A question waiting for the user’s answer.

Source

pub fn origin(self, origin: Origin) -> Self

Source

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

Why (left out when blank).

Source

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

What to do (left out when blank).

Source

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

The technical chain (left out when blank).

Source

pub fn details_from(self, err: &(dyn Error + 'static)) -> Self

The chain of an error and its sources, one per line.

Source

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

A button, after the others.

Source

pub fn action_with( self, id: impl Into<String>, label: impl Into<String>, args: Value, ) -> Self

A button whose command runs with args, after the others: “Undo this restore” ({"restore": 7}). The arguments are kept with the notice, saved with it, and given to the command when the button runs it, from a toast, a notice site or the Notices panel.

Source

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

Source

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

Source

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

The node it happened on; its origin becomes Origin::Node.

Trait Implementations§

Source§

impl Clone for Notice

Source§

fn clone(&self) -> Notice

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Notice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Notice

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Notice

Source§

fn eq(&self, other: &Notice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Notice

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Notice

Auto Trait Implementations§

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,