Trait ca_formats::Input

source ·
pub trait Input {
    type Lines: Iterator;
    type Line: AsRef<str>;
    type Bytes: Iterator<Item = u8>;

    // Required methods
    fn lines(self) -> Self::Lines;
    fn line(item: <Self::Lines as Iterator>::Item) -> Result<Self::Line, Error>;
    fn bytes(line: Self::Line) -> Self::Bytes;
}
Expand description

Types that can be passed to parsers as input.

The trait is implemented for &str, &[u8], BufReader, and &mut B for every type B that implements BufRead.

When parsing a file, you can take a BufReader<File> as input.

Required Associated Types§

source

type Lines: Iterator

An iterator over lines of the input.

source

type Line: AsRef<str>

A string or a reference to a string, which represents a line of the input.

source

type Bytes: Iterator<Item = u8>

An iterator over bytes of a line.

Required Methods§

source

fn lines(self) -> Self::Lines

Creates an iterator over lines from the input.

source

fn line(item: <Self::Lines as Iterator>::Item) -> Result<Self::Line, Error>

Converts a item in the lines iterator to a string.

source

fn bytes(line: Self::Line) -> Self::Bytes

Creates an iterator over bytes from a line.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a> Input for &'a str

§

type Lines = Lines<'a>

§

type Line = &'a str

§

type Bytes = Bytes<'a>

source§

fn lines(self) -> Self::Lines

source§

fn line(item: <Self::Lines as Iterator>::Item) -> Result<Self::Line, Error>

source§

fn bytes(line: Self::Line) -> Self::Bytes

source§

impl<'a> Input for &'a [u8]

§

type Lines = Lines<&'a [u8]>

§

type Line = String

§

type Bytes = IntoIter<u8>

source§

fn lines(self) -> Self::Lines

source§

fn line(item: <Self::Lines as Iterator>::Item) -> Result<Self::Line, Error>

source§

fn bytes(line: Self::Line) -> Self::Bytes

source§

impl<'a> Input for Lines<'a>

§

type Lines = Lines<'a>

§

type Line = &'a str

§

type Bytes = Bytes<'a>

source§

fn lines(self) -> Self::Lines

source§

fn line(item: <Self::Lines as Iterator>::Item) -> Result<Self::Line, Error>

source§

fn bytes(line: Self::Line) -> Self::Bytes

source§

impl<'a, B: BufRead> Input for &'a mut B

§

type Lines = Lines<&'a mut B>

§

type Line = String

§

type Bytes = IntoIter<u8>

source§

fn lines(self) -> Self::Lines

source§

fn line(item: <Self::Lines as Iterator>::Item) -> Result<Self::Line, Error>

source§

fn bytes(line: Self::Line) -> Self::Bytes

source§

impl<B: BufRead> Input for Lines<B>

§

type Lines = Lines<B>

§

type Line = String

§

type Bytes = IntoIter<u8>

source§

fn lines(self) -> Self::Lines

source§

fn line(item: <Self::Lines as Iterator>::Item) -> Result<Self::Line, Error>

source§

fn bytes(line: Self::Line) -> Self::Bytes

source§

impl<R: Read> Input for BufReader<R>

§

type Lines = Lines<BufReader<R>>

§

type Line = String

§

type Bytes = IntoIter<u8>

source§

fn lines(self) -> Self::Lines

source§

fn line(item: <Self::Lines as Iterator>::Item) -> Result<Self::Line, Error>

source§

fn bytes(line: Self::Line) -> Self::Bytes

Implementors§