Struct kas::widgets::edit::InstantParseGuard
source · pub struct InstantParseGuard<A, T>{ /* private fields */ }
Expand description
An as-you-type EditGuard
for parsable types
This guard displays a value formatted from input data, updates the error state according to parse success on each keystroke, and sends a message immediately (where successful parsing occurred).
Implementations§
source§impl<A, T> InstantParseGuard<A, T>
impl<A, T> InstantParseGuard<A, T>
sourcepub fn new<M>(
value_fn: impl Fn(&A) -> T + 'static,
on_afl: impl Fn(T) -> M + 'static
) -> InstantParseGuard<A, T>where
M: Debug + 'static,
pub fn new<M>(
value_fn: impl Fn(&A) -> T + 'static,
on_afl: impl Fn(T) -> M + 'static
) -> InstantParseGuard<A, T>where
M: Debug + 'static,
Construct
On update, value_fn
is used to extract a value from input data
which is then formatted as a string via Display
.
If, however, the input field has focus, the update is ignored.
On every edit, the guard attempts to parse the field’s input as type
T
via FromStr
. On success, the result is converted to a
message via on_afl
then emitted via EventCx::push
.
Trait Implementations§
source§impl<A, T> Debug for InstantParseGuard<A, T>
impl<A, T> Debug for InstantParseGuard<A, T>
source§impl<A, T> EditGuard for InstantParseGuard<A, T>
impl<A, T> EditGuard for InstantParseGuard<A, T>
source§fn focus_lost(
edit: &mut EditField<InstantParseGuard<A, T>>,
cx: &mut EventCx<'_>,
data: &A
)
fn focus_lost( edit: &mut EditField<InstantParseGuard<A, T>>, cx: &mut EventCx<'_>, data: &A )
Focus-lost guard Read more
source§fn edit(
edit: &mut EditField<InstantParseGuard<A, T>>,
cx: &mut EventCx<'_>,
_: &A
)
fn edit( edit: &mut EditField<InstantParseGuard<A, T>>, cx: &mut EventCx<'_>, _: &A )
Edit guard Read more
source§fn update(
edit: &mut EditField<InstantParseGuard<A, T>>,
cx: &mut ConfigCx<'_>,
data: &A
)
fn update( edit: &mut EditField<InstantParseGuard<A, T>>, cx: &mut ConfigCx<'_>, data: &A )
Update guard Read more
Auto Trait Implementations§
impl<A, T> !RefUnwindSafe for InstantParseGuard<A, T>
impl<A, T> !Send for InstantParseGuard<A, T>
impl<A, T> !Sync for InstantParseGuard<A, T>
impl<A, T> Unpin for InstantParseGuard<A, T>
impl<A, T> !UnwindSafe for InstantParseGuard<A, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
§fn cast_approx(self) -> T
fn cast_approx(self) -> T
§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
§fn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
§fn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
§fn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
§fn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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
.§fn as_any(&self) -> &(dyn Any + 'static)
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.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.