pub struct FormInputBuilder { /* private fields */ }
Implementations§
source§impl FormInputBuilder
impl FormInputBuilder
pub fn new() -> Self
sourcepub fn label_field(self, text: &str) -> Self
pub fn label_field(self, text: &str) -> Self
Form Field: Text output
sourcepub fn separator_field(self) -> Self
pub fn separator_field(self) -> Self
Form Field: Vertical spacing
sourcepub fn text_field(self, prompt: &str, default: Option<&str>) -> Self
pub fn text_field(self, prompt: &str, default: Option<&str>) -> Self
Form Field: Prompt for a string value
sourcepub fn multiline_field(self, prompt: &str, default: Option<&str>) -> Self
pub fn multiline_field(self, prompt: &str, default: Option<&str>) -> Self
Form Field: Prompt for multi-line string value
sourcepub fn integer_field(self, prompt: &str, default: Option<i64>) -> Self
pub fn integer_field(self, prompt: &str, default: Option<i64>) -> Self
Form Field: Prompt for an integer
sourcepub fn address_field(
self,
prompt: &str,
view: Option<Ref<BinaryView>>,
current_address: Option<u64>,
default: Option<u64>,
) -> Self
pub fn address_field( self, prompt: &str, view: Option<Ref<BinaryView>>, current_address: Option<u64>, default: Option<u64>, ) -> Self
Form Field: Prompt for an address
sourcepub fn choice_field(
self,
prompt: &str,
choices: &[&str],
default: Option<usize>,
) -> Self
pub fn choice_field( self, prompt: &str, choices: &[&str], default: Option<usize>, ) -> Self
Form Field: Prompt for a choice from provided options
sourcepub fn open_file_field(
self,
prompt: &str,
ext: Option<&str>,
default: Option<&str>,
) -> Self
pub fn open_file_field( self, prompt: &str, ext: Option<&str>, default: Option<&str>, ) -> Self
Form Field: Prompt for file to open
sourcepub fn save_file_field(
self,
prompt: &str,
ext: Option<&str>,
default_name: Option<&str>,
default: Option<&str>,
) -> Self
pub fn save_file_field( self, prompt: &str, ext: Option<&str>, default_name: Option<&str>, default: Option<&str>, ) -> Self
Form Field: Prompt for file to save to
sourcepub fn directory_name_field(
self,
prompt: &str,
default_name: Option<&str>,
default: Option<&str>,
) -> Self
pub fn directory_name_field( self, prompt: &str, default_name: Option<&str>, default: Option<&str>, ) -> Self
Form Field: Prompt for directory name
sourcepub fn get_form_input(&mut self, title: &str) -> Vec<FormResponses>
pub fn get_form_input(&mut self, title: &str) -> Vec<FormResponses>
Prompts the user for a set of inputs specified in fields
with given title.
The fields parameter is a list which can contain the following types:
This API is flexible and works both in the UI via a pop-up dialog and on the command-line.
let responses = FormInputBuilder::new()
.text_field("First Name", None)
.text_field("Last Name", None)
.choice_field(
"Favorite Food",
&vec![
"Pizza",
"Also Pizza",
"Also Pizza",
"Yummy Pizza",
"Wrong Answer",
],
Some(0),
)
.get_form_input("Form Title");
let food = match responses[2] {
FormResponses::Index(0) => "Pizza",
FormResponses::Index(1) => "Also Pizza",
FormResponses::Index(2) => "Also Pizza",
FormResponses::Index(3) => "Wrong Answer",
_ => panic!("This person doesn't like pizza?!?"),
};
let FormResponses::String(last_name) = &responses[0] else {
unreachable!()
};
let FormResponses::String(first_name) = &responses[1] else {
unreachable!()
};
println!("{} {} likes {}", &first_name, &last_name, food);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FormInputBuilder
impl RefUnwindSafe for FormInputBuilder
impl !Send for FormInputBuilder
impl !Sync for FormInputBuilder
impl Unpin for FormInputBuilder
impl UnwindSafe for FormInputBuilder
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