Skip to main content

Digits

Struct Digits 

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

Large digit display widget

Implementations§

Source§

impl Digits

Source

pub fn new(value: impl ToString) -> Self

Create new digits display from a number

Source

pub fn from_int(value: i64) -> Self

Create from integer

Source

pub fn from_float(value: f64, decimals: usize) -> Self

Create from float with decimal places

Source

pub fn time(hours: u32, minutes: u32, seconds: u32) -> Self

Create time display (HH:MM:SS)

Source

pub fn clock(hours: u32, minutes: u32) -> Self

Create clock display (HH:MM)

Source

pub fn timer(total_seconds: u64) -> Self

Create timer display from seconds

Source

pub fn style(self, style: DigitStyle) -> Self

Set display style

Source

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

Set foreground color

Source

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

Set background color

Source

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

Set prefix (displayed before digits)

Source

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

Set suffix (displayed after digits)

Source

pub fn separator(self, sep: char) -> Self

Set thousands separator

Source

pub fn min_width(self, width: usize) -> Self

Set minimum width (pads with zeros)

Source

pub fn leading_zeros(self, show: bool) -> Self

Show leading zeros

Source

pub fn height(&self) -> usize

Get the height of digits in this style

Source

pub fn digit_width(&self) -> usize

Get the width of a single digit in this style

Source

pub fn render_lines(&self) -> Vec<String>

Render to lines

Source§

impl Digits

Source

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

Set element ID for CSS selector (#id)

Source

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

Add a CSS class

Source

pub fn classes<I, S>(self, classes: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add multiple CSS classes

Trait Implementations§

Source§

impl Clone for Digits

Source§

fn clone(&self) -> Digits

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 Digits

Source§

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

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

impl StyledView for Digits

Source§

fn set_id(&mut self, id: impl Into<String>)

Set element ID
Source§

fn add_class(&mut self, class: impl Into<String>)

Add a CSS class
Source§

fn remove_class(&mut self, class: &str)

Remove a CSS class
Source§

fn toggle_class(&mut self, class: &str)

Toggle a CSS class
Source§

fn has_class(&self, class: &str) -> bool

Check if has class
Source§

impl View for Digits

Source§

fn id(&self) -> Option<&str>

Get element ID (for CSS #id selectors) Read more
Source§

fn classes(&self) -> &[String]

Get CSS classes (for CSS .class selectors) Read more
Source§

fn meta(&self) -> WidgetMeta

Get widget metadata for DOM Read more
Source§

fn render(&self, ctx: &mut RenderContext<'_>)

Render the view to the given context Read more
Source§

fn widget_type(&self) -> &'static str

Get widget type name (for CSS type selectors) Read more
Source§

fn children(&self) -> &[Box<dyn View>]

Get child views (for container widgets) Read more

Auto Trait Implementations§

§

impl Freeze for Digits

§

impl RefUnwindSafe for Digits

§

impl Send for Digits

§

impl Sync for Digits

§

impl Unpin for Digits

§

impl UnwindSafe for Digits

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.