Trait SourceContent

Source
pub trait SourceContent {
    // Required methods
    fn iter(&self) -> Box<CharIter<'_>>;
    fn iter_from(&self, offset: usize) -> Box<CharIter<'_>>;
    fn extract(&self, begin: usize, end: usize) -> String;
    fn extract_iter(&self, begin: usize, end: usize) -> Box<CharIter<'_>>;
    fn bytes(&self) -> &[u8] ;
    fn lines(&self) -> &[usize];
}

Required Methods§

Source

fn iter(&self) -> Box<CharIter<'_>>

Obtain an iterator over the characters within the source file, together with their respective byte positions.

Source

fn iter_from(&self, offset: usize) -> Box<CharIter<'_>>

Obtain an iterator over the characters within the source file, starting at the provided location offset, together with their respective byte positions.

Source

fn extract(&self, begin: usize, end: usize) -> String

Copy a range of the source content into a String instance owned by the caller, possibly converting the encoding such that the result is in UTF-8.

Source

fn extract_iter(&self, begin: usize, end: usize) -> Box<CharIter<'_>>

Obtain an iterator over an extract of the source content. This might be more efficient than copying the extract into a String.

Source

fn bytes(&self) -> &[u8]

Obtain a slice voer all bytes within the source file. This is the fastest way of getting at the file’s contents, since no parsing or character encoding is performed or assumed.

Source

fn lines(&self) -> &[usize]

Return a list of byte offsets indicating the start of lines.

Implementors§