Struct bdrck::cli::MaybePromptedString
source · pub struct MaybePromptedString { /* private fields */ }
Expand description
MaybePromptedString is a wrapper for getting user input interactively, while also allowing the value to be specified at call time. This is useful e.g. when we want to prompt users interactively, but want to predefine the values in unit tests, or when users can specify a value either interactively or via flags.
Implementations§
source§impl MaybePromptedString
impl MaybePromptedString
sourcepub fn new<IS: AbstractStream, OS: AbstractStream>(
provided: Option<&str>,
input_stream: IS,
output_stream: OS,
prompt: &str,
is_sensitive: bool,
confirm: bool
) -> Result<Self>
pub fn new<IS: AbstractStream, OS: AbstractStream>( provided: Option<&str>, input_stream: IS, output_stream: OS, prompt: &str, is_sensitive: bool, confirm: bool ) -> Result<Self>
Construct a new MaybePromptedString, either using the given value or prompting the user interactively with the given options.
sourcepub fn was_provided(&self) -> bool
pub fn was_provided(&self) -> bool
Returns true if this string was provided, or false if it is the result of an interactive prompt.
sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
“Unwraps” this structure into its underlying string.
Auto Trait Implementations§
impl RefUnwindSafe for MaybePromptedString
impl Send for MaybePromptedString
impl Sync for MaybePromptedString
impl Unpin for MaybePromptedString
impl UnwindSafe for MaybePromptedString
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