impl Debug for Store

This commit is contained in:
Matthias Beyer 2016-03-25 13:29:20 +01:00
parent 22052ba9f0
commit c5c60cf36d

View file

@ -7,11 +7,15 @@ use std::sync::Arc;
use std::sync::RwLock; use std::sync::RwLock;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::{Seek, SeekFrom}; use std::io::{Seek, SeekFrom};
use std::io::Write;
use std::convert::From; use std::convert::From;
use std::convert::Into; use std::convert::Into;
use std::sync::Mutex; use std::sync::Mutex;
use std::ops::Deref; use std::ops::Deref;
use std::ops::DerefMut; use std::ops::DerefMut;
use std::fmt::Formatter;
use std::fmt::Debug;
use std::fmt::Error as FMTError;
use toml::{Table, Value}; use toml::{Table, Value};
use regex::Regex; use regex::Regex;
@ -33,7 +37,7 @@ use hook::Hook;
pub type Result<T> = RResult<T, StoreError>; pub type Result<T> = RResult<T, StoreError>;
#[derive(PartialEq)] #[derive(Debug, PartialEq)]
enum StoreEntryStatus { enum StoreEntryStatus {
Present, Present,
Borrowed Borrowed
@ -41,6 +45,7 @@ enum StoreEntryStatus {
/// A store entry, depending on the option type it is either borrowed currently /// A store entry, depending on the option type it is either borrowed currently
/// or not. /// or not.
#[derive(Debug)]
struct StoreEntry { struct StoreEntry {
id: StoreId, id: StoreId,
file: LazyFile, file: LazyFile,
@ -505,6 +510,32 @@ impl Store {
} }
impl Debug for Store {
fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FMTError> {
try!(write!(fmt, " --- Store ---\n"));
try!(write!(fmt, "\n"));
try!(write!(fmt, " - location : {:?}\n", self.location));
try!(write!(fmt, " - configuration : {:?}\n", self.configuration));
try!(write!(fmt, " - pre_read_aspects : {:?}\n", self.pre_read_aspects ));
try!(write!(fmt, " - post_read_aspects : {:?}\n", self.post_read_aspects ));
try!(write!(fmt, " - pre_create_aspects : {:?}\n", self.pre_create_aspects ));
try!(write!(fmt, " - post_create_aspects : {:?}\n", self.post_create_aspects ));
try!(write!(fmt, " - pre_retrieve_aspects : {:?}\n", self.pre_retrieve_aspects ));
try!(write!(fmt, " - post_retrieve_aspects : {:?}\n", self.post_retrieve_aspects ));
try!(write!(fmt, " - pre_update_aspects : {:?}\n", self.pre_update_aspects ));
try!(write!(fmt, " - post_update_aspects : {:?}\n", self.post_update_aspects ));
try!(write!(fmt, " - pre_delete_aspects : {:?}\n", self.pre_delete_aspects ));
try!(write!(fmt, " - post_delete_aspects : {:?}\n", self.post_delete_aspects ));
try!(write!(fmt, "\n"));
try!(write!(fmt, "Entries:\n"));
try!(write!(fmt, "{:?}", self.entries));
try!(write!(fmt, "\n"));
Ok(())
}
}
impl Drop for Store { impl Drop for Store {
/** /**