Trait smart_read::TryRead

source ·
pub trait TryRead<'a> {
    type Output;
    type Default;

    // Required method
    fn try_read_line(
        &'a self,
        prompt: Option<String>,
        default: Option<Self::Default>,
    ) -> BoxResult<Self::Output>;
}
Expand description

This is what powers the whole crate. Any struct that implements this can be used with the macros

Required Associated Types§

source

type Output

Defines the output type of read and prompt macros

source

type Default

Defines the output type of the default input

Required Methods§

source

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

This is what’s called by the read and prompt macros

Implementations on Foreign Types§

source§

impl<'a> TryRead<'a> for ()

§

type Output = String

§

type Default = &'a str

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

source§

impl<'a, Data: 'a> TryRead<'a> for &[InputOption<Data>]

§

type Output = (usize, &'a InputOption<Data>)

§

type Default = usize

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

source§

impl<'a, Data: 'a, const LEN: usize> TryRead<'a> for &[InputOption<Data>; LEN]

§

type Output = (usize, &'a InputOption<Data>)

§

type Default = usize

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

source§

impl<'a, T> TryRead<'a> for Range<T>
where T: Display + FromStr + PartialOrd<T>, <T as FromStr>::Err: Display,

§

type Output = T

§

type Default = T

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Output>, ) -> BoxResult<Self::Output>

source§

impl<'a, T> TryRead<'a> for RangeFrom<T>
where T: Display + FromStr + PartialOrd<T>, <T as FromStr>::Err: Display,

§

type Output = T

§

type Default = T

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Output>, ) -> BoxResult<Self::Output>

source§

impl<'a, T> TryRead<'a> for RangeInclusive<T>
where T: Display + FromStr + PartialOrd<T>, <T as FromStr>::Err: Display,

§

type Output = T

§

type Default = T

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Output>, ) -> BoxResult<Self::Output>

source§

impl<'a, T> TryRead<'a> for RangeTo<T>
where T: Display + FromStr + PartialOrd<T>, <T as FromStr>::Err: Display,

§

type Output = T

§

type Default = T

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Output>, ) -> BoxResult<Self::Output>

source§

impl<'a, T> TryRead<'a> for RangeToInclusive<T>
where T: Display + FromStr + PartialOrd<T>, <T as FromStr>::Err: Display,

§

type Output = T

§

type Default = T

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Output>, ) -> BoxResult<Self::Output>

source§

impl<'a, T: Display + 'a> TryRead<'a> for &'a [T]

§

type Output = (usize, &'a T)

§

type Default = usize

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

source§

impl<'a, T: Display + 'a> TryRead<'a> for LinkedList<T>

§

type Output = (usize, &'a T)

§

type Default = usize

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

source§

impl<'a, T: Display + 'a> TryRead<'a> for VecDeque<T>

§

type Output = (usize, &'a T)

§

type Default = usize

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

source§

impl<'a, T: Display + 'a> TryRead<'a> for Vec<T>

§

type Output = (usize, &'a T)

§

type Default = usize

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

source§

impl<'a, T: Display + 'a, const LEN: usize> TryRead<'a> for &[T; LEN]

§

type Output = (usize, &'a T)

§

type Default = usize

source§

fn try_read_line( &'a self, prompt: Option<String>, default: Option<Self::Default>, ) -> BoxResult<Self::Output>

Implementors§

source§

impl<'a> TryRead<'a> for BoolInput

source§

impl<'a> TryRead<'a> for CharInput

source§

impl<'a> TryRead<'a> for F32Input

§

type Output = f32

§

type Default = f32

source§

impl<'a> TryRead<'a> for F64Input

§

type Output = f64

§

type Default = f64

source§

impl<'a> TryRead<'a> for I8Input

§

type Output = i8

§

type Default = i8

source§

impl<'a> TryRead<'a> for I16Input

§

type Output = i16

§

type Default = i16

source§

impl<'a> TryRead<'a> for I32Input

§

type Output = i32

§

type Default = i32

source§

impl<'a> TryRead<'a> for I64Input

§

type Output = i64

§

type Default = i64

source§

impl<'a> TryRead<'a> for I128Input

source§

impl<'a> TryRead<'a> for IsizeInput

source§

impl<'a> TryRead<'a> for NonEmptyInput

§

type Output = String

§

type Default = &'a str

source§

impl<'a> TryRead<'a> for NonWhitespaceInput

§

type Output = String

§

type Default = &'a str

source§

impl<'a> TryRead<'a> for U8Input

§

type Output = u8

§

type Default = u8

source§

impl<'a> TryRead<'a> for U16Input

§

type Output = u16

§

type Default = u16

source§

impl<'a> TryRead<'a> for U32Input

§

type Output = u32

§

type Default = u32

source§

impl<'a> TryRead<'a> for U64Input

§

type Output = u64

§

type Default = u64

source§

impl<'a> TryRead<'a> for U128Input

source§

impl<'a> TryRead<'a> for UsizeInput

source§

impl<'a> TryRead<'a> for YesNoInput

source§

impl<'a, F: Fn(&str) -> Result<(), String>> TryRead<'a> for SimpleValidate<F>

§

type Output = String

§

type Default = &'a str

source§

impl<'a, F: Fn(String) -> Result<O, String>, O: Display + 'a> TryRead<'a> for TransformValidate<F, O>

§

type Output = O

§

type Default = O