aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 45d4843..be8993b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -107,17 +107,14 @@ impl WALFile for WALFileAIO {
}
async fn write(&self, offset: WALPos, data: WALBytes) -> Result<(), ()> {
- self.aiomgr
- .write(self.fd, offset, data, None)
- .await
- .or_else(|_| Err(()))
- .and_then(|(nwrote, data)| {
- if nwrote == data.len() {
- Ok(())
- } else {
- Err(())
- }
- })
+ let (res, data) = self.aiomgr.write(self.fd, offset, data, None).await;
+ res.or_else(|_| Err(())).and_then(|nwrote| {
+ if nwrote == data.len() {
+ Ok(())
+ } else {
+ Err(())
+ }
+ })
}
fn read(
@@ -125,11 +122,11 @@ impl WALFile for WALFileAIO {
offset: WALPos,
length: usize,
) -> Result<Option<WALBytes>, ()> {
- block_on(self.aiomgr.read(self.fd, offset, length, None))
- .or_else(|_| Err(()))
- .and_then(|(nread, data)| {
- Ok(if nread == length { Some(data) } else { None })
- })
+ let (res, data) =
+ block_on(self.aiomgr.read(self.fd, offset, length, None));
+ res.or_else(|_| Err(())).and_then(|nread| {
+ Ok(if nread == length { Some(data) } else { None })
+ })
}
}