From 5b6bb306bb1d20bdab0e1d7752f2b7b7f16a2b7e Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 12 Jun 2020 14:30:12 -0400 Subject: async write works --- examples/demo1.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/demo1.rs b/examples/demo1.rs index 5ee2b64..a360885 100644 --- a/examples/demo1.rs +++ b/examples/demo1.rs @@ -91,16 +91,17 @@ impl Drop for WALStoreTest { } } +#[async_trait(?Send)] impl WALStore for WALStoreTest { type FileNameIter = std::vec::IntoIter; - fn open_file(&mut self, filename: &str, touch: bool) -> Result, ()> { + async fn open_file(&self, filename: &str, touch: bool) -> Result, ()> { println!("open_file(filename={}, touch={})", filename, touch); let filename = filename.to_string(); WALFileTest::new(self.rootfd, &filename).and_then(|f| Ok(Box::new(f) as Box)) } - fn remove_file(&mut self, filename: &str) -> Result<(), ()> { + fn remove_file(&self, filename: &str) -> Result<(), ()> { println!("remove_file(filename={})", filename); unlinkat(Some(self.rootfd), filename, UnlinkatFlags::NoRemoveDir).or_else(|_| Err(())) } @@ -114,7 +115,7 @@ impl WALStore for WALStoreTest { Ok(logfiles.into_iter()) } - fn apply_payload(&mut self, payload: WALBytes, ringid: WALRingId) -> Result<(), ()> { + fn apply_payload(&self, payload: WALBytes, ringid: WALRingId) -> Result<(), ()> { println!("apply_payload(payload={}, ringid={:?})", std::str::from_utf8(&payload).unwrap(), ringid); -- cgit v1.2.3