diff --git a/examples/Cargo.toml b/examples/Cargo.toml index acaf97e..af9a129 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -14,3 +14,5 @@ tokio = ["dep:tokio", "fusio/tokio"] fusio = { path = "../fusio" } monoio = { version = "0.2", optional = true } tokio = { version = "1.0", features = ["full"], optional = true } +fusio-opendal = { path = "../fusio-opendal" } +opendal = { version = "0.50.1", default-features = false, features = ["services-memory"] } \ No newline at end of file diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 8f9da44..c3e7a55 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -1,6 +1,7 @@ mod fs; mod multi_runtime; mod object; +mod opendal; mod s3; use fusio::{Error, IoBuf, IoBufMut, Read, Write}; diff --git a/examples/src/opendal.rs b/examples/src/opendal.rs new file mode 100644 index 0000000..68c8bcd --- /dev/null +++ b/examples/src/opendal.rs @@ -0,0 +1,22 @@ +use fusio::{dynamic::DynFile, DynFs}; +use fusio_opendal::OpendalFs; +use opendal::services::Memory; +use opendal::Operator; +use std::sync::Arc; + +#[allow(unused)] +async fn use_opendalfs() { + let op = Operator::new(Memory::default()).unwrap().finish(); + let fs: Arc = Arc::new(OpendalFs::from(op)); + + let mut file: Box = Box::new(fs.open(&"foo.txt".into()).await.unwrap()); + + let write_buf = "hello, world".as_bytes(); + let mut read_buf = [0; 12]; + + let (result, _, read_buf) = + crate::write_without_runtime_awareness(&mut file, write_buf, &mut read_buf[..]).await; + result.unwrap(); + + assert_eq!(&read_buf, b"hello, world"); +}