pub trait ReadOneFrom: Sized {
type ParseError: Error;
// Required method
fn parse(s: &str) -> Result<Self, ReadError<Self::ParseError>>;
// Provided methods
fn accept() -> impl Pattern<Item = char> { ... }
fn try_read_one_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Self, ReadError<Self::ParseError>> { ... }
fn try_read_in_char_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Self, ReadError<Self::ParseError>> { ... }
fn try_read_in_line_trimmed_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Self, ReadError<Self::ParseError>> { ... }
fn try_read_in_line_some_trimmed_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Self, ReadError<Self::ParseError>> { ... }
fn try_read_all_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Vec<Self>, ReadError<Self::ParseError>> { ... }
fn try_read_any_in_line_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Vec<Self>, ReadError<Self::ParseError>> { ... }
fn try_read_some_in_line_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Vec<Self>, ReadError<Self::ParseError>> { ... }
}
Expand description
Read a single data item from input stream.
All types that implement this trait also implement ReadFrom.
§Errors
- If the input cannot be parsed into
T
, ReadError::FromStrError is returned. - If the input is not valid UTF-8, ReadError::IOError is returned.
- If an I/O error occurs, ReadError::IOError is returned.
Required Associated Types§
Sourcetype ParseError: Error
type ParseError: Error
Errors that come from parsing.
Required Methods§
Provided Methods§
Sourcefn try_read_one_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Self, ReadError<Self::ParseError>>
fn try_read_one_from<F: Format, S: BufReadExt>( stream: &mut S, format: F, ) -> Result<Self, ReadError<Self::ParseError>>
Read from stream
and parse into Self
.
Sourcefn try_read_in_char_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Self, ReadError<Self::ParseError>>
fn try_read_in_char_from<F: Format, S: BufReadExt>( stream: &mut S, format: F, ) -> Result<Self, ReadError<Self::ParseError>>
Read an element in a single non-whitespace character from stream
, parse into Self
.
Sourcefn try_read_in_line_trimmed_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Self, ReadError<Self::ParseError>>
fn try_read_in_line_trimmed_from<F: Format, S: BufReadExt>( stream: &mut S, format: F, ) -> Result<Self, ReadError<Self::ParseError>>
Read an element in the remained line from stream
, parse into Self
.
Sourcefn try_read_in_line_some_trimmed_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Self, ReadError<Self::ParseError>>
fn try_read_in_line_some_trimmed_from<F: Format, S: BufReadExt>( stream: &mut S, format: F, ) -> Result<Self, ReadError<Self::ParseError>>
Read an element in a single trimmed line that is not empty from stream
, parse into Self
.
Sourcefn try_read_all_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Vec<Self>, ReadError<Self::ParseError>>
fn try_read_all_from<F: Format, S: BufReadExt>( stream: &mut S, format: F, ) -> Result<Vec<Self>, ReadError<Self::ParseError>>
Read all remaining elements from stream
into a Vec of Self
.
Sourcefn try_read_any_in_line_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Vec<Self>, ReadError<Self::ParseError>>
fn try_read_any_in_line_from<F: Format, S: BufReadExt>( stream: &mut S, format: F, ) -> Result<Vec<Self>, ReadError<Self::ParseError>>
Read all elements in current line from stream
into a Vec of Self
.
Sourcefn try_read_some_in_line_from<F: Format, S: BufReadExt>(
stream: &mut S,
format: F,
) -> Result<Vec<Self>, ReadError<Self::ParseError>>
fn try_read_some_in_line_from<F: Format, S: BufReadExt>( stream: &mut S, format: F, ) -> Result<Vec<Self>, ReadError<Self::ParseError>>
Read all elements in a non-empty line from stream
into a Vec of Self
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.