Skip to main content

DateFieldState

Struct DateFieldState 

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

Controlled segmented editing state for one date field.

The application owns every visible declaration: separators, widths, colors, the placeholder look, and the focused-segment highlight. QuickGUI owns the calendar contract — leap years, month lengths, wrapping steps, typed-digit entry with automatic advance, bounded validation — plus which segment is being edited and the native spin-button semantics of each one.

The state retains one bounded placeholder string per segment and no task, timer, observer, or idle scheduler source.

Implementations§

Source§

impl DateFieldState

Source

pub fn new() -> Self

An empty field whose first segment owns editing focus.

Source

pub fn from_date(date: CivilDate) -> Self

A field holding one complete date. An invalid date is clamped before it is retained.

Source

pub fn order(self, order: DateFieldOrder) -> Self

Declare the segment order the application lays out.

Source

pub fn minimum(self, minimum: CivilDate) -> Self

Reject dates before this day. The bound is reported through validity, never by rewriting what the user typed.

Source

pub fn maximum(self, maximum: CivilDate) -> Self

Reject dates after this day.

Source

pub fn placeholder( self, segment: DateSegment, text: impl Into<Arc<str>>, ) -> Self

Replace one segment’s placeholder. Longer text than MAX_DATE_FIELD_PLACEHOLDER_BYTES keeps the default.

Source

pub const fn disabled(self, disabled: bool) -> Self

Source

pub const fn segment_order(&self) -> DateFieldOrder

Source

pub const fn minimum_date(&self) -> Option<CivilDate>

Source

pub const fn maximum_date(&self) -> Option<CivilDate>

Source

pub const fn is_disabled(&self) -> bool

Source

pub fn value(&self) -> Option<CivilDate>

The complete date, or None while any segment is empty or the combination is not real.

Source

pub fn set_value(&mut self, value: Option<CivilDate>) -> bool

Replace the value. None clears every segment.

Source

pub const fn segment_value(&self, segment: DateSegment) -> Option<i32>

The raw numeric content of one segment.

Source

pub const fn is_filled(&self, segment: DateSegment) -> bool

Source

pub const fn is_complete(&self) -> bool

Whether every segment holds a value.

Source

pub fn is_valid(&self) -> bool

Whether the field is empty or holds a real date inside its declared bounds.

A partly typed date is invalid: that is what a form needs to reject, and it matches the desktop and web behavior of a segmented date control.

Source

pub fn placeholder_text(&self, segment: DateSegment) -> &Arc<str> ⓘ

Source

pub fn segment_text(&self, segment: DateSegment) -> String

The text one segment displays: zero-padded digits, or its placeholder while empty.

Source

pub const fn focused_segment(&self) -> DateSegment

Source

pub fn focus_segment(&mut self, segment: DateSegment) -> bool

Move editing focus to one segment, discarding pending typed digits.

Source

pub fn focus_next(&mut self) -> bool

Move to the next segment in the declared order. The final segment reports false so Tab can leave the field instead of trapping focus.

Source

pub fn focus_previous(&mut self) -> bool

Move to the previous segment in the declared order.

Source

pub fn segment_bounds(&self, segment: DateSegment) -> (i32, i32)

The inclusive numeric range one segment accepts right now.

The day’s maximum honors the retained month and year, so February in a leap year offers 29.

Source

pub fn step_segment(&mut self, segment: DateSegment, delta: i32) -> bool

Step one segment, wrapping at its bounds. An empty segment takes its minimum when stepped forward and its maximum when stepped backward.

Source

pub fn increment(&mut self) -> bool

Step the focused segment one unit toward its maximum.

Source

pub fn decrement(&mut self) -> bool

Step the focused segment one unit toward its minimum.

Source

pub fn to_segment_minimum(&mut self) -> bool

Set the focused segment to its smallest legal value.

Source

pub fn to_segment_maximum(&mut self) -> bool

Set the focused segment to its largest legal value.

Source

pub fn clear_segment(&mut self) -> bool

Clear the focused segment and any pending typed digits.

Source

pub fn clear(&mut self) -> bool

Clear every segment.

Source

pub fn type_digit(&mut self, digit: u8) -> bool

Type one ASCII digit into the focused segment.

The segment advances as soon as no further digit could fit: a month of 4, a day of 9, or a complete four-digit year all move editing to the next segment immediately.

Source

pub fn type_character(&mut self, character: char) -> bool

Type one printable character. Only ASCII digits change a date field.

Trait Implementations§

Source§

impl Clone for DateFieldState

Source§

fn clone(&self) -> DateFieldState

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 DateFieldState

Source§

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

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

impl Default for DateFieldState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for DateFieldState

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DateFieldState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Action for T
where T: Clone + PartialEq + 'static,

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> Downcast for T
where T: Any,

Source§

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

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

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

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

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

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

Source§

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further 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.

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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
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> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
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<T> Upcast<T> for T

Source§

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

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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

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