Impl Store::retrieve() interface
This commit is contained in:
parent
bc3a82fcc6
commit
ce8c382e81
1 changed files with 24 additions and 1 deletions
|
@ -164,7 +164,30 @@ methods!(
|
|||
// On error: Nil + Exception
|
||||
//
|
||||
fn retrieve(id: RStoreId) -> AnyObject {
|
||||
unimplemented!()
|
||||
use entry::FileLockEntryHandle;
|
||||
let sid = typecheck!(id or return any NilClass::new()).unwrap().clone();
|
||||
|
||||
call_on_store! {
|
||||
store <- itself wrapped inside STORE_WRAPPER,
|
||||
operation {
|
||||
match store.retrieve(sid.clone()) {
|
||||
Err(e) => {
|
||||
trace_error(&e);
|
||||
VM::raise(Class::from_existing("RuntimeError"), e.description());
|
||||
NilClass::new().to_any_object()
|
||||
},
|
||||
Ok(entry) => {
|
||||
// Take the location (StoreId) of the entry (we know it exists... so this
|
||||
// is fine) and wrap it into a RFileLockEntry which is then returned to the
|
||||
// user (as handle)
|
||||
let sid = entry.get_location().clone();
|
||||
let store_handle = itself.get_data(&*STORE_WRAPPER).clone();
|
||||
FileLockEntryHandle::new(store_handle, sid).wrap()
|
||||
},
|
||||
}
|
||||
},
|
||||
on fail return NilClass::new().to_any_object()
|
||||
}
|
||||
}
|
||||
|
||||
// Get an FileLockEntry from the store
|
||||
|
|
Loading…
Reference in a new issue