Struct exar::Log
[−]
[src]
pub struct Log { // some fields omitted }
Exar DB's log file abstraction.
It offers helper methods to manage a log file and its index. It also allows to open readers and writers for the log file.
Examples
extern crate exar; use exar::*; let log = Log::new("/path/to/logs", "test", 100); let exists = log.ensure_exists().unwrap(); let writer = log.open_writer().unwrap(); let reader = log.open_reader().unwrap(); let index = log.compute_index().unwrap(); log.remove().unwrap();
Methods
impl Log
[src]
fn new(path: &str, name: &str, index_granularity: u64) -> Log
Returns a new Log
pointing to the given path/name and using the given index granularity.
fn ensure_exists(&self) -> Result<(), DatabaseError>
Ensure the underlying log file exists and creates it if it does not exist,
it returns a DatabaseError
if a failure occurs while creating the log file.
fn open_reader(&self) -> Result<BufReader<File>, DatabaseError>
Returns a buffered reader for the underlying log file
or a DatabaseError
if a failure occurs.
fn open_line_reader(&self) -> Result<IndexedLineReader<BufReader<File>>, DatabaseError>
Returns an indexed line reader for the underlying log file
or a DatabaseError
if a failure occurs.
fn open_line_reader_with_index(&self, index: LinesIndex) -> Result<IndexedLineReader<BufReader<File>>, DatabaseError>
Returns an indexed line reader for the underlying log file and restores the index
using the given LinesIndex
or a DatabaseError
if a failure occurs.
fn open_writer(&self) -> Result<BufWriter<File>, DatabaseError>
Returns a buffered writer for the underlying log file or a DatabaseError
if a failure occurs.
fn remove(&self) -> Result<(), DatabaseError>
Removes the underlying log file and its index or a DatabaseError
if a failure occurs.
fn compute_index(&self) -> Result<LinesIndex, DatabaseError>
Computes and returns the LinesIndex
for the underlying log file
or a DatabaseError
if a failure occurs.
fn open_index_reader(&self) -> Result<BufReader<File>, DatabaseError>
Returns a buffered reader for the log index file or a DatabaseError
if a failure occurs.
fn open_index_writer(&self) -> Result<BufWriter<File>, DatabaseError>
Returns a buffered writer for the log index file or a DatabaseError
if a failure occurs.
fn restore_index(&self) -> Result<LinesIndex, DatabaseError>
Restores and returns the log LinesIndex
from the log index file
or a DatabaseError
if a failure occurs.
If the log index file does not exist it will be computed and persisted.
fn persist_index(&self, index: &LinesIndex) -> Result<(), DatabaseError>
Persists the given LinesIndex
to a log index file
or returns a DatabaseError
if a failure occurs.
fn get_path(&self) -> String
Returns the path to the log file.
fn get_index_path(&self) -> String
Returns the path to the log index file.
fn get_index_granularity(&self) -> u64
Returns the lines index granularity for the log file.
Trait Implementations
impl Eq for Log
[src]
impl PartialEq for Log
[src]
fn eq(&self, __arg_0: &Log) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Log) -> bool
This method tests for !=
.
impl Debug for Log
[src]
impl Clone for Log
[src]
fn clone(&self) -> Log
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more