summaryrefslogtreecommitdiffstats
path: root/lib/core/libimagstore/src/file_abstraction
diff options
context:
space:
mode:
Diffstat (limited to 'lib/core/libimagstore/src/file_abstraction')
-rw-r--r--lib/core/libimagstore/src/file_abstraction/fs.rs20
-rw-r--r--lib/core/libimagstore/src/file_abstraction/inmemory.rs6
-rw-r--r--lib/core/libimagstore/src/file_abstraction/stdio/mapper/json.rs10
-rw-r--r--lib/core/libimagstore/src/file_abstraction/stdio/mod.rs9
-rw-r--r--lib/core/libimagstore/src/file_abstraction/stdio/out.rs2
5 files changed, 23 insertions, 24 deletions
diff --git a/lib/core/libimagstore/src/file_abstraction/fs.rs b/lib/core/libimagstore/src/file_abstraction/fs.rs
index 0773a178..7dad3361 100644
--- a/lib/core/libimagstore/src/file_abstraction/fs.rs
+++ b/lib/core/libimagstore/src/file_abstraction/fs.rs
@@ -48,8 +48,8 @@ impl FileAbstractionInstance for FSFileAbstractionInstance {
FSFileAbstractionInstance::File(ref mut f, _) => return {
// We seek to the beginning of the file since we expect each
// access to the file to be in a different context
- try!(f.seek(SeekFrom::Start(0))
- .chain_err(|| SEK::FileNotSeeked));
+ f.seek(SeekFrom::Start(0))
+ .chain_err(|| SEK::FileNotSeeked)?;
let mut s = String::new();
f.read_to_string(&mut s)
@@ -58,7 +58,7 @@ impl FileAbstractionInstance for FSFileAbstractionInstance {
.and_then(|s| Entry::from_str(id, &s))
},
FSFileAbstractionInstance::Absent(ref p) =>
- (try!(open_file(p).chain_err(|| SEK::FileNotFound)), p.clone()),
+ (open_file(p).chain_err(|| SEK::FileNotFound)?, p.clone()),
};
*self = FSFileAbstractionInstance::File(file, path);
if let FSFileAbstractionInstance::File(ref mut f, _) = *self {
@@ -84,15 +84,15 @@ impl FileAbstractionInstance for FSFileAbstractionInstance {
FSFileAbstractionInstance::File(ref mut f, _) => return {
// We seek to the beginning of the file since we expect each
// access to the file to be in a different context
- try!(f.seek(SeekFrom::Start(0))
- .chain_err(|| SEK::FileNotCreated));
+ f.seek(SeekFrom::Start(0))
+ .chain_err(|| SEK::FileNotCreated)?;
- try!(f.set_len(buf.len() as u64).chain_err(|| SEK::FileNotWritten));
+ f.set_len(buf.len() as u64).chain_err(|| SEK::FileNotWritten)?;
f.write_all(&buf).chain_err(|| SEK::FileNotWritten)
},
FSFileAbstractionInstance::Absent(ref p) =>
- (try!(create_file(p).chain_err(|| SEK::FileNotCreated)), p.clone()),
+ (create_file(p).chain_err(|| SEK::FileNotCreated)?, p.clone()),
};
*self = FSFileAbstractionInstance::File(file, path);
if let FSFileAbstractionInstance::File(ref mut f, _) = *self {
@@ -129,7 +129,7 @@ impl FileAbstraction for FSFileAbstraction {
match to.parent() {
Some(p) => if !p.exists() {
debug!("Creating: {:?}", p);
- let _ = try!(create_dir_all(&PathBuf::from(p)));
+ let _ = create_dir_all(&PathBuf::from(p))?;
},
None => {
debug!("Failed to find parent. This looks like it will fail now");
@@ -184,11 +184,11 @@ impl FileAbstraction for FSFileAbstraction {
})
.fold(Ok(vec![]), |acc, e| {
acc.and_then(move |mut a| {
- a.push(try!(e));
+ a.push(e?);
Ok(a)
})
});
- Ok(PathIterator::new(Box::new(try!(i).into_iter())))
+ Ok(PathIterator::new(Box::new(i?.into_iter())))
}
}
diff --git a/lib/core/libimagstore/src/file_abstraction/inmemory.rs b/lib/core/libimagstore/src/file_abstraction/inmemory.rs
index 9a9adf67..094a5af0 100644
--- a/lib/core/libimagstore/src/file_abstraction/inmemory.rs
+++ b/lib/core/libimagstore/src/file_abstraction/inmemory.rs
@@ -131,7 +131,7 @@ impl FileAbstraction for InMemoryFileAbstraction {
let mut mtx = self.backend().lock().expect("Locking Mutex failed");
let backend = mtx.get_mut();
- let a = try!(backend.get(from).cloned().ok_or(SE::from_kind(SEK::FileNotFound)));
+ let a = backend.get(from).cloned().ok_or(SE::from_kind(SEK::FileNotFound))?;
backend.insert(to.clone(), a);
debug!("Copying: {:?} -> {:?} worked", from, to);
Ok(())
@@ -142,7 +142,7 @@ impl FileAbstraction for InMemoryFileAbstraction {
let mut mtx = self.backend().lock().expect("Locking Mutex failed");
let backend = mtx.get_mut();
- let a = try!(backend.get(from).cloned().ok_or(SE::from_kind(SEK::FileNotFound)));
+ let a = backend.get(from).cloned().ok_or(SE::from_kind(SEK::FileNotFound))?;
backend.insert(to.clone(), a);
debug!("Renaming: {:?} -> {:?} worked", from, to);
Ok(())
@@ -176,7 +176,7 @@ impl FileAbstraction for InMemoryFileAbstraction {
fn fill<'a>(&'a mut self, mut d: Drain) -> Result<(), SE> {
debug!("Draining into : {:?}", self);
- let mut mtx = try!(self.backend().lock().map_err(|_| SEK::LockError));
+ let mut mtx = self.backend().lock().map_err(|_| SEK::LockError)?;
let backend = mtx.get_mut();
for (path, element) in d.iter() {
diff --git a/lib/core/libimagstore/src/file_abstraction/stdio/mapper/json.rs b/lib/core/libimagstore/src/file_abstraction/stdio/mapper/json.rs
index 3bd46d6c..7bc8fc9d 100644
--- a/lib/core/libimagstore/src/file_abstraction/stdio/mapper/json.rs
+++ b/lib/core/libimagstore/src/file_abstraction/stdio/mapper/json.rs
@@ -73,15 +73,15 @@ impl Mapper for JsonMapper {
let mut document = {
debug!("Reading Document");
let mut s = String::new();
- try!(r.read_to_string(&mut s).chain_err(|| SEK::IoError));
+ r.read_to_string(&mut s).chain_err(|| SEK::IoError)?;
debug!("Document = {:?}", s);
debug!("Parsing Document");
- let doc : Document = try!(serde_json::from_str(&s).chain_err(|| SEK::IoError));
+ let doc : Document = serde_json::from_str(&s).chain_err(|| SEK::IoError)?;
debug!("Document = {:?}", doc);
doc
};
- let _ = try!(::semver::Version::parse(&document.version)
+ let _ = ::semver::Version::parse(&document.version)
.chain_err(|| SEK::VersionError)
.and_then(|doc_vers| {
// safe because cargo does not compile if crate version is not valid
@@ -96,7 +96,7 @@ impl Mapper for JsonMapper {
} else {
Ok(())
}
- }));
+ })?;
for (key, val) in document.store.drain() {
debug!("(key, value) ({:?}, {:?})", key, val);
@@ -110,7 +110,7 @@ impl Mapper for JsonMapper {
})
.map(|_| ());
- let _ = try!(res);
+ let _ = res?;
}
Ok(())
diff --git a/lib/core/libimagstore/src/file_abstraction/stdio/mod.rs b/lib/core/libimagstore/src/file_abstraction/stdio/mod.rs
index 7bf4f425..5b93f6f0 100644
--- a/lib/core/libimagstore/src/file_abstraction/stdio/mod.rs
+++ b/lib/core/libimagstore/src/file_abstraction/stdio/mod.rs
@@ -56,11 +56,10 @@ impl<W, M> StdIoFileAbstraction<W, M>
pub fn new<R: Read>(in_stream: &mut R, out_stream: Rc<RefCell<W>>, mapper: M) -> Result<StdIoFileAbstraction<W, M>, SE> {
StdoutFileAbstraction::new(out_stream, mapper)
.and_then(|out| {
- let _ = try!(out
- .backend()
- .lock()
- .map_err(|_| SE::from_kind(SEK::LockError))
- .map(|mut mtx| out.mapper().read_to_fs(in_stream, mtx.get_mut())));
+ let _ = out.backend()
+ .lock()
+ .map_err(|_| SE::from_kind(SEK::LockError))
+ .map(|mut mtx| out.mapper().read_to_fs(in_stream, mtx.get_mut()))?;
Ok(StdIoFileAbstraction(out))
})
diff --git a/lib/core/libimagstore/src/file_abstraction/stdio/out.rs b/lib/core/libimagstore/src/file_abstraction/stdio/out.rs
index c8540b33..5f62e899 100644
--- a/lib/core/libimagstore/src/file_abstraction/stdio/out.rs
+++ b/lib/core/libimagstore/src/file_abstraction/stdio/out.rs
@@ -150,7 +150,7 @@ impl<W: Write, M: Mapper> FileAbstraction for StdoutFileAbstraction<W, M> {
fn fill(&mut self, mut d: Drain) -> Result<(), SE> {
debug!("Draining into : {:?}", self);
- let mut mtx = try!(self.backend().lock().map_err(|_| SE::from_kind(SEK::IoError)));
+ let mut mtx = self.backend().lock().map_err(|_| SE::from_kind(SEK::IoError))?;
let backend = mtx.get_mut();
for (path, element) in d.iter() {