pub trait InteractiveWidget:
Debug
+ Send
+ Sync {
// Required methods
fn id(&self) -> &str;
fn widget_type(&self) -> WidgetType;
fn update_data(&mut self, data: Value) -> Result<()>;
fn handle_interaction(
&mut self,
event: WidgetEvent,
) -> Result<Option<WidgetEventResponse>>;
fn render(&self, context: &RenderContext) -> Result<WidgetRender>;
fn config(&self) -> &WidgetConfig;
fn update_config(&mut self, config: WidgetConfig) -> Result<()>;
fn state(&self) -> Value;
fn restore_state(&mut self, state: Value) -> Result<()>;
fn validate_data(&self, data: &Value) -> Result<()>;
}Expand description
Interactive widget trait
Required Methods§
Sourcefn widget_type(&self) -> WidgetType
fn widget_type(&self) -> WidgetType
Get widget type
Sourcefn update_data(&mut self, data: Value) -> Result<()>
fn update_data(&mut self, data: Value) -> Result<()>
Update widget with new data
Sourcefn handle_interaction(
&mut self,
event: WidgetEvent,
) -> Result<Option<WidgetEventResponse>>
fn handle_interaction( &mut self, event: WidgetEvent, ) -> Result<Option<WidgetEventResponse>>
Handle user interaction
Sourcefn render(&self, context: &RenderContext) -> Result<WidgetRender>
fn render(&self, context: &RenderContext) -> Result<WidgetRender>
Render widget to context
Sourcefn config(&self) -> &WidgetConfig
fn config(&self) -> &WidgetConfig
Get widget configuration
Sourcefn update_config(&mut self, config: WidgetConfig) -> Result<()>
fn update_config(&mut self, config: WidgetConfig) -> Result<()>
Update widget configuration
Sourcefn restore_state(&mut self, state: Value) -> Result<()>
fn restore_state(&mut self, state: Value) -> Result<()>
Restore from state
Sourcefn validate_data(&self, data: &Value) -> Result<()>
fn validate_data(&self, data: &Value) -> Result<()>
Validate widget data