From c5c60cf36d8c9096fe3a974c57f449c0f173d4e5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 25 Mar 2016 13:29:20 +0100 Subject: [PATCH] impl Debug for Store --- libimagstore/src/store.rs | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index ab895a5b..061f3ef3 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -7,11 +7,15 @@ use std::sync::Arc; use std::sync::RwLock; use std::collections::BTreeMap; use std::io::{Seek, SeekFrom}; +use std::io::Write; use std::convert::From; use std::convert::Into; use std::sync::Mutex; use std::ops::Deref; use std::ops::DerefMut; +use std::fmt::Formatter; +use std::fmt::Debug; +use std::fmt::Error as FMTError; use toml::{Table, Value}; use regex::Regex; @@ -33,7 +37,7 @@ use hook::Hook; pub type Result = RResult; -#[derive(PartialEq)] +#[derive(Debug, PartialEq)] enum StoreEntryStatus { Present, Borrowed @@ -41,6 +45,7 @@ enum StoreEntryStatus { /// A store entry, depending on the option type it is either borrowed currently /// or not. +#[derive(Debug)] struct StoreEntry { id: StoreId, 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 { /**