Fix libimagcounter::counter::* for new StoreId interface
This commit is contained in:
parent
138e506882
commit
f3727ca686
2 changed files with 14 additions and 7 deletions
|
@ -48,8 +48,10 @@ impl<'a> Counter<'a> {
|
||||||
|
|
||||||
debug!("Creating new counter: '{}' with value: {}", name, init);
|
debug!("Creating new counter: '{}' with value: {}", name, init);
|
||||||
let fle = {
|
let fle = {
|
||||||
let mut lockentry = try!(store.create(ModuleEntryPath::new(name.clone()).into_storeid())
|
let id = try!(ModuleEntryPath::new(name.clone())
|
||||||
|
.into_storeid()
|
||||||
.map_err_into(CEK::StoreWriteError));
|
.map_err_into(CEK::StoreWriteError));
|
||||||
|
let mut lockentry = try!(store.create(id).map_err_into(CEK::StoreWriteError));
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut entry = lockentry.deref_mut();
|
let mut entry = lockentry.deref_mut();
|
||||||
|
@ -161,14 +163,18 @@ impl<'a> Counter<'a> {
|
||||||
|
|
||||||
pub fn load(name: CounterName, store: &Store) -> Result<Counter> {
|
pub fn load(name: CounterName, store: &Store) -> Result<Counter> {
|
||||||
debug!("Loading counter: '{}'", name);
|
debug!("Loading counter: '{}'", name);
|
||||||
let id = ModuleEntryPath::new(name).into_storeid();
|
let id = try!(ModuleEntryPath::new(name)
|
||||||
|
.into_storeid()
|
||||||
|
.map_err_into(CEK::StoreWriteError));
|
||||||
Counter::from_storeid(store, id)
|
Counter::from_storeid(store, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(name: CounterName, store: &Store) -> Result<()> {
|
pub fn delete(name: CounterName, store: &Store) -> Result<()> {
|
||||||
debug!("Deleting counter: '{}'", name);
|
debug!("Deleting counter: '{}'", name);
|
||||||
store.delete(ModuleEntryPath::new(name).into_storeid())
|
let id = try!(ModuleEntryPath::new(name)
|
||||||
.map_err_into(CEK::StoreWriteError)
|
.into_storeid()
|
||||||
|
.map_err_into(CEK::StoreWriteError));
|
||||||
|
store.delete(id).map_err_into(CEK::StoreWriteError)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn all_counters(store: &Store) -> Result<CounterIterator> {
|
pub fn all_counters(store: &Store) -> Result<CounterIterator> {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
generate_error_module!(
|
generate_error_module!(
|
||||||
generate_error_types!(CounterError, CounterErrorKind,
|
generate_error_types!(CounterError, CounterErrorKind,
|
||||||
|
StoreIdError => "StoreId error",
|
||||||
StoreReadError => "Store read error",
|
StoreReadError => "Store read error",
|
||||||
StoreWriteError => "Store write error",
|
StoreWriteError => "Store write error",
|
||||||
HeaderTypeError => "Header type error",
|
HeaderTypeError => "Header type error",
|
||||||
|
|
Loading…
Reference in a new issue