Skip to main content

Stat

Struct Stat 

Source
pub struct Stat { /* private fields */ }
Expand description

One figure of a stats row: what it counts, the value, and optionally a line under it, an icon, a link, a trend and a sparkline.

Stat::new("Revenue", "$12,400")
    .detail("8% more than last month")
    .trend(Trend::Up)
    .color(Color::Success)
    .chart([9.1, 10.2, 11.0, 12.4]);

Implementations§

Source§

impl Stat

Source

pub async fn records<R: Resource>(cx: &Cx) -> Result<Option<Self>>

How many records of R the request may see, under R’s sidebar label and icon, linking to its list; None when the request may not open that list, so no tile counts records it cannot see or links to a list that would answer 403.

The count reads scoped_query: the caller’s tenant, R’s query, and no trashed record.

§Errors

The database’s, when the count fails.

Source§

impl Stat

Source

pub fn new(label: impl Into<Text>, value: impl Into<String>) -> Self

A figure labelled label, with value already formatted: "1,204", "98%".

Source

pub fn detail(self, detail: impl Into<Text>) -> Self

The line under the value, such as "12 this week".

Source

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

The icon before the label.

Source

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

The URL the whole tile links to, such as the list the figure counts.

Source

pub fn trend(self, trend: Trend) -> Self

Which way the figure moved, as an arrow before the detail line; a stat with no detail line shows none.

Source

pub fn color(self, color: Color) -> Self

The color of the detail line and the sparkline; defaults to Color::Gray, muted. A trend is good or bad only for the figure it moves, so the color is the caller’s to pick.

Source

pub fn chart(self, values: impl IntoIterator<Item = f64>) -> Self

The values the tile draws as a sparkline under the value, oldest first. Fewer than two finite values draw none.

Trait Implementations§

Source§

impl Clone for Stat

Source§

fn clone(&self) -> Self

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

impl Debug for Stat

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Stat

§

impl !UnwindSafe for Stat

§

impl Forget for Stat

§

impl Freeze for Stat

§

impl Move for Stat

§

impl Send for Stat

§

impl Sync for Stat

§

impl Unpin for Stat

§

impl UnsafeUnpin for Stat

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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