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

Methods

impl Larry
[src]

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.

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.

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());

Auto Trait Implementations

impl Send for Larry

impl Sync for Larry