pub struct ParseGuard<A, T>{ /* private fields */ }Expand description
An 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 on focus loss (where successful parsing occurred).
Implementations§
Source§impl<A, T> ParseGuard<A, T>
impl<A, T> ParseGuard<A, T>
Sourcepub fn new<M>(
value_fn: impl Fn(&A) -> T + 'static,
on_afl: impl Fn(T) -> M + 'static,
) -> ParseGuard<A, T>where
M: Debug + 'static,
pub fn new<M>(
value_fn: impl Fn(&A) -> T + 'static,
on_afl: impl Fn(T) -> M + 'static,
) -> ParseGuard<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, caching the result and setting the error state.
On field activation and focus loss when a T value is cached (see
previous paragraph), on_afl is used to construct a message to be
emitted via EventCx::push. The cached value is then cleared to
avoid sending duplicate messages.
Trait Implementations§
Source§impl<A, T> Debug for ParseGuard<A, T>
impl<A, T> Debug for ParseGuard<A, T>
Source§impl<A, T> EditGuard for ParseGuard<A, T>
impl<A, T> EditGuard for ParseGuard<A, T>
Source§fn focus_lost(
edit: &mut EditField<ParseGuard<A, T>>,
cx: &mut EventCx<'_>,
data: &A,
)
fn focus_lost( edit: &mut EditField<ParseGuard<A, T>>, cx: &mut EventCx<'_>, data: &A, )
Source§fn edit(edit: &mut EditField<ParseGuard<A, T>>, cx: &mut EventCx<'_>, _: &A)
fn edit(edit: &mut EditField<ParseGuard<A, T>>, cx: &mut EventCx<'_>, _: &A)
Source§fn update(
edit: &mut EditField<ParseGuard<A, T>>,
cx: &mut ConfigCx<'_>,
data: &A,
)
fn update( edit: &mut EditField<ParseGuard<A, T>>, cx: &mut ConfigCx<'_>, data: &A, )
Auto Trait Implementations§
impl<A, T> Freeze for ParseGuard<A, T>where
T: Freeze,
impl<A, T> !RefUnwindSafe for ParseGuard<A, T>
impl<A, T> !Send for ParseGuard<A, T>
impl<A, T> !Sync for ParseGuard<A, T>
impl<A, T> Unpin for ParseGuard<A, T>where
T: Unpin,
impl<A, T> !UnwindSafe for ParseGuard<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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more