pub struct WizardStep {
pub name: String,
pub form: Form,
pub condition: Option<Box<dyn Fn(&HashMap<String, HashMap<String, Value>>) -> bool + Send + Sync>>,
}Expand description
A single step in the wizard
Fields§
§name: String§form: Form§condition: Option<Box<dyn Fn(&HashMap<String, HashMap<String, Value>>) -> bool + Send + Sync>>Implementations§
Source§impl WizardStep
impl WizardStep
Sourcepub fn new(name: String, form: Form) -> Self
pub fn new(name: String, form: Form) -> Self
Create a new wizard step
§Examples
use reinhardt_forms::{WizardStep, Form};
let form = Form::new();
let step = WizardStep::new("step1".to_string(), form);
assert_eq!(step.name, "step1");Sourcepub fn with_condition<F>(self, condition: F) -> Self
pub fn with_condition<F>(self, condition: F) -> Self
Add a condition for when this step should be available
§Examples
use reinhardt_forms::{WizardStep, Form};
use std::collections::HashMap;
use serde_json::json;
let form = Form::new();
let step = WizardStep::new("step2".to_string(), form)
.with_condition(|data| {
data.get("step1").map_or(false, |step1_data| {
step1_data.get("age").and_then(|v| v.as_i64()).map_or(false, |age| age >= 18)
})
});pub fn is_available( &self, session_data: &HashMap<String, HashMap<String, Value>>, ) -> bool
Auto Trait Implementations§
impl Freeze for WizardStep
impl !RefUnwindSafe for WizardStep
impl Send for WizardStep
impl Sync for WizardStep
impl Unpin for WizardStep
impl UnsafeUnpin for WizardStep
impl !UnwindSafe for WizardStep
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