pub struct RestorableNum<T: RestorableNumValue> { /* private fields */ }Expand description
A RestorableProperty that knows how to store and restore a number.
The current value of this property is stored in the restoration data. During state restoration the property is restored to the value it had when the restoration data it is getting restored from was collected.
If no restoration data is available, the value is initialized to the default_value given in
the constructor.
Instead of using the more generic RestorableNum directly, consider using one of the more
specific aliases (RestorableDouble to store an f64 and RestorableInt to store an
i64).
See also:
RestorableNumNfor the nullable version of this property.
Implementations§
Source§impl<T: RestorableNumValue> RestorableNum<T>
impl<T: RestorableNumValue> RestorableNum<T>
Sourcepub fn new(app: &mut App, default_value: T) -> Ref<RestorableNum<T>>
pub fn new(app: &mut App, default_value: T) -> Ref<RestorableNum<T>>
Creates a RestorableNum.
If no restoration data is available to restore the value in this property from, the
property will be initialized with the provided default_value.
Trait Implementations§
Source§impl<T: RestorableNumValue> ChangeNotifier for RestorableNum<T>
impl<T: RestorableNumValue> ChangeNotifier for RestorableNum<T>
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
Runs before the listener is stored. Dart overrides of
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
Runs after the listener is removed. Dart overrides of
removeListener that
work after super.removeListener go here.impl<T: RestorableNumValue> RestorablePrimitiveValue for RestorableNum<T>
Source§impl<T: RestorableNumValue> RestorablePrimitiveValueN for RestorableNum<T>
impl<T: RestorableNumValue> RestorablePrimitiveValueN for RestorableNum<T>
Source§fn restorable_primitive_value_data(
self: Handle<Self>,
app: &App,
) -> &RestorablePrimitiveValueData<Self::Value>
fn restorable_primitive_value_data( self: Handle<Self>, app: &App, ) -> &RestorablePrimitiveValueData<Self::Value>
Dart’s
_RestorablePrimitiveValueN._defaultValue, held under the field primitive
(restorable_primitive_value_accessors!).Source§fn restorable_primitive_value_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut RestorablePrimitiveValueData<Self::Value>
fn restorable_primitive_value_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut RestorablePrimitiveValueData<Self::Value>
Source§fn create_default_value(self: Handle<Self>, app: &mut App) -> Self::Value
fn create_default_value(self: Handle<Self>, app: &mut App) -> Self::Value
Dart’s
_RestorablePrimitiveValueN.createDefaultValue.Source§fn did_update_value(
self: Handle<Self>,
app: &mut App,
old_value: Option<Self::Value>,
)
fn did_update_value( self: Handle<Self>, app: &mut App, old_value: Option<Self::Value>, )
Dart’s
_RestorablePrimitiveValueN.didUpdateValue.Source§fn from_primitives(
self: Handle<Self>,
app: &mut App,
data: &RestorationData,
) -> Self::Value
fn from_primitives( self: Handle<Self>, app: &mut App, data: &RestorationData, ) -> Self::Value
Dart’s
_RestorablePrimitiveValueN.fromPrimitives.Source§fn to_primitives(self: Handle<Self>, app: &App) -> RestorationData
fn to_primitives(self: Handle<Self>, app: &App) -> RestorationData
Dart’s
_RestorablePrimitiveValueN.toPrimitives.Source§impl<T: RestorableNumValue> RestorableProperty for RestorableNum<T>
impl<T: RestorableNumValue> RestorableProperty for RestorableNum<T>
Source§fn restorable_property_data(
self: Handle<Self>,
app: &App,
) -> &RestorablePropertyData
fn restorable_property_data( self: Handle<Self>, app: &App, ) -> &RestorablePropertyData
The registration with a
RestorationMixin, held under the field property
(restorable_property_accessors!).Source§fn restorable_property_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut RestorablePropertyData
fn restorable_property_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut RestorablePropertyData
Source§fn create_default_value(self: Handle<Self>, app: &mut App) -> T
fn create_default_value(self: Handle<Self>, app: &mut App) -> T
Called by the
RestorationMixin if no restoration data is available to restore the
value of the property from, to obtain the default value for the property. Read moreSource§fn from_primitives(
self: Handle<Self>,
app: &mut App,
data: &RestorationData,
) -> T
fn from_primitives( self: Handle<Self>, app: &mut App, data: &RestorationData, ) -> T
Called by the
RestorationMixin to convert the data previously retrieved from
to_primitives back into an object of type
Value that this property should wrap. Read moreSource§fn init_with_value(self: Handle<Self>, app: &mut App, value: T)
fn init_with_value(self: Handle<Self>, app: &mut App, value: T)
Called by the
RestorationMixin with the value returned by either
create_default_value or
from_primitives to set the value that this property currently
wraps. Read moreSource§fn to_primitives(self: Handle<Self>, app: &App) -> RestorationData
fn to_primitives(self: Handle<Self>, app: &App) -> RestorationData
Called by the
RestorationMixin to retrieve the information that this property wants
to store in the restoration data. Read moreSource§fn enabled(self: Handle<Self>, app: &App) -> bool
fn enabled(self: Handle<Self>, app: &App) -> bool
Whether the object currently returned by
to_primitives should
be included in the restoration state. Read moreSource§fn dispose_property(self: Handle<Self>, app: &mut App)
fn dispose_property(self: Handle<Self>, app: &mut App)
Dart’s
RestorableProperty.dispose body. An override that runs super.dispose()
calls this.Source§fn dispose(self: Handle<Self>, app: &mut App)
fn dispose(self: Handle<Self>, app: &mut App)
Discards any resources used by the property, unregistering it from its owner.
Source§fn did_dispose(self: Handle<Self>, app: &mut App)
fn did_dispose(self: Handle<Self>, app: &mut App)
Runs at the end of
dispose: what a Dart override does after its
super.dispose() call.Source§fn is_registered(self: Handle<Self>, app: &App) -> bool
fn is_registered(self: Handle<Self>, app: &App) -> bool
Whether this property is currently registered with a
RestorationMixin.Source§fn as_property(self: Handle<Self>) -> AnyRestorableProperty
fn as_property(self: Handle<Self>) -> AnyRestorableProperty
This property as the erased
AnyRestorableProperty — what to pass where a Dart API
takes a RestorableProperty<Object?>.Source§impl<T: RestorableNumValue> RestorableValue for RestorableNum<T>
impl<T: RestorableNumValue> RestorableValue for RestorableNum<T>
Source§fn restorable_value_data(
self: Handle<Self>,
app: &App,
) -> &RestorableValueData<Self::Value>
fn restorable_value_data( self: Handle<Self>, app: &App, ) -> &RestorableValueData<Self::Value>
Source§fn restorable_value_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut RestorableValueData<Self::Value>
fn restorable_value_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut RestorableValueData<Self::Value>
Source§fn value(self: Handle<Self>, app: &App) -> &Self::Value
fn value(self: Handle<Self>, app: &App) -> &Self::Value
The current value stored in this property. Read more
Source§fn set_value(self: Handle<Self>, app: &mut App, new_value: Self::Value)
fn set_value(self: Handle<Self>, app: &mut App, new_value: Self::Value)
Replaces
value, calling
did_update_value when it changes.Source§fn init_with_value(self: Handle<Self>, app: &mut App, value: Self::Value)
fn init_with_value(self: Handle<Self>, app: &mut App, value: Self::Value)
Dart’s
RestorableValue.initWithValue: the value the
RestorationMixin restored or defaulted becomes
value.Source§fn debug_assert_valid_value(
self: Handle<Self>,
app: &App,
new_value: &Self::Value,
) -> bool
fn debug_assert_valid_value( self: Handle<Self>, app: &App, new_value: &Self::Value, ) -> bool
Checks what Dart asserts inside a
set value override before running the inherited
setter; RestorableEnum and RestorableEnumN check membership in their values. Read moreAuto Trait Implementations§
impl<T> !RefUnwindSafe for RestorableNum<T>
impl<T> !Send for RestorableNum<T>
impl<T> !Sync for RestorableNum<T>
impl<T> !UnwindSafe for RestorableNum<T>
impl<T> Forget for RestorableNum<T>
impl<T> Freeze for RestorableNum<T>
impl<T> Move for RestorableNum<T>
impl<T> Unpin for RestorableNum<T>
impl<T> UnsafeUnpin for RestorableNum<T>where
*const u8 is !null: UnsafeUnpin,
PhantomData<Option<Listener>>: UnsafeUnpin,
*const RcInner<Cell<usize>> is !null: UnsafeUnpin,
PhantomData<RcInner<Cell<usize>>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
&'static RestorationMixinVTable: UnsafeUnpin,
T: UnsafeUnpin,
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