DataContract
trait · ferroui-reactiveui · v0.5.0
trait DataContract: IReactiveObject
A reactive object whose type declares which of its properties are persisted: the counterpart
of [DataContract] with [DataMember] on the properties, which upstream reads by reflection.
use ferroui_reactiveui::{reactive_object, reactive_properties, AutoPersistMetadata, DataContract, ReactiveObject};
reactive_properties! {
#[derive(Default)]
pub struct Settings {
reactive: ReactiveObject,
#[reactive]
user_name: String,
#[reactive]
window_title: String,
}
}
reactive_object!(Settings);
impl DataContract for Settings {
fn data_members() -> &'static [&'static str] {
&["UserName"]
}
}
let metadata = AutoPersistMetadata::for_type::<Settings>();
assert!(metadata.has_data_contract());
assert!(metadata.persistable_property_names().contains("UserName"));
assert!(!metadata.persistable_property_names().contains("WindowTitle"));
Members
data_members
fn data_members() -> &'static [&'static str]
The names of the persisted properties, in PascalCase (the properties with [DataMember]).
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.