pub struct RestorableEnum<T: Copy + Debug + PartialEq + 'static> { /* private fields */ }Expand description
A RestorableProperty that knows how to store and restore an enum.
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.
The values are serialized using the name of the variant, obtained from its Debug.
The set of values the property may represent is values, which the
constructor takes.
See also:
RestorableEnumN, which knows how to store and restore nullable enums.
Implementations§
Source§impl<T: Copy + Debug + PartialEq + 'static> RestorableEnum<T>
impl<T: Copy + Debug + PartialEq + 'static> RestorableEnum<T>
Sourcepub fn new(
app: &mut App,
default_value: T,
values: impl IntoIterator<Item = T>,
) -> Ref<RestorableEnum<T>>
pub fn new( app: &mut App, default_value: T, values: impl IntoIterator<Item = T>, ) -> Ref<RestorableEnum<T>>
Creates a RestorableEnum.
If no restoration data is available to restore the value in this property from, the
property will be initialized with the provided default_value.
Sourcepub fn values(self: Handle<Self>, app: &App) -> &[T]
pub fn values(self: Handle<Self>, app: &App) -> &[T]
The set of values that this RestorableEnum may represent.
This supplies the enum values that are serialized and restored. If a value is
encountered that is not in this set,
from_primitives asserts when restoring.
It is typically every variant of the enum type.
Sourcepub fn set_values(
self: Handle<Self>,
app: &mut App,
values: impl IntoIterator<Item = T>,
)
pub fn set_values( self: Handle<Self>, app: &mut App, values: impl IntoIterator<Item = T>, )
See values.
Trait Implementations§
Source§impl<T: Copy + Debug + PartialEq + 'static> ChangeNotifier for RestorableEnum<T>
impl<T: Copy + Debug + PartialEq + 'static> ChangeNotifier for RestorableEnum<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)
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)
removeListener that
work after super.removeListener go here.Source§impl<T: Copy + Debug + PartialEq + 'static> RestorableProperty for RestorableEnum<T>
impl<T: Copy + Debug + PartialEq + 'static> RestorableProperty for RestorableEnum<T>
Source§fn restorable_property_data(
self: Handle<Self>,
app: &App,
) -> &RestorablePropertyData
fn restorable_property_data( self: Handle<Self>, app: &App, ) -> &RestorablePropertyData
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
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
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)
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
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
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)
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)
Source§fn did_dispose(self: Handle<Self>, app: &mut App)
fn did_dispose(self: Handle<Self>, app: &mut App)
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
RestorationMixin.Source§fn as_property(self: Handle<Self>) -> AnyRestorableProperty
fn as_property(self: Handle<Self>) -> AnyRestorableProperty
AnyRestorableProperty — what to pass where a Dart API
takes a RestorableProperty<Object?>.Source§impl<T: Copy + Debug + PartialEq + 'static> RestorableValue for RestorableEnum<T>
impl<T: Copy + Debug + PartialEq + 'static> RestorableValue for RestorableEnum<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 debug_assert_valid_value(
self: Handle<Self>,
app: &App,
new_value: &T,
) -> bool
fn debug_assert_valid_value( self: Handle<Self>, app: &App, new_value: &T, ) -> bool
set value override before running the inherited
setter; RestorableEnum and RestorableEnumN check membership in their values. Read moreSource§fn value(self: Handle<Self>, app: &App) -> &Self::Value
fn value(self: Handle<Self>, app: &App) -> &Self::Value
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)
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)
RestorableValue.initWithValue: the value the
RestorationMixin restored or defaulted becomes
value.