Struct larry::Larry [−][src]
pub struct Larry { pub file: File, // some fields omitted }
A Larry
is a "line array". It allows one to access a file as a
lazily-read array of lines. This allows efficient random access to large
files such as log files.
Fields
file: File
Methods
impl Larry
[src]
impl Larry
pub fn new(path: &Path) -> Result<Larry, Error>
[src]
pub fn new(path: &Path) -> Result<Larry, Error>
Constructs a new Larry
.
Construction requires that the file be scanned for line-terminal byte sequences.
Examples
use larry::Larry; use std::path::Path; let mut larry = Larry::new(Path::new("production.log"));
Errors
Any std::io::Error
arising while opening the file and scanning its contents
for line endings will be returned.
pub fn get(&mut self, i: usize) -> Result<String, String>
[src]
pub fn get(&mut self, i: usize) -> Result<String, String>
Obtain a particular line.
Examples
use larry::Larry; use std::path::Path; let mut larry = Larry::new(Path::new("production.log")); print!("{}", larry.get(larry.len() - 1).unwrap()); // print the last line of the file
Errors
Index bound errors if you ask for a line beyond the end of the file and IO errors if the file has changed since the larry was created.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns number of lines.
Examples
use larry::Larry; use std::path::Path; let mut larry = Larry::new(Path::new("production.log")); println!("number of lines line: {}", larry.len());