| commit | c465bb6e594d8cfdff68332111a67abea2e89cf5 | [log] [tgz] |
|---|---|---|
| author | Xuanwo <github@xuanwo.io> | Wed Feb 23 17:44:15 2022 +0800 |
| committer | GitHub <noreply@github.com> | Wed Feb 23 17:44:15 2022 +0800 |
| tree | 6624f8de18ed23697307996f27d7c31f237476fb | |
| parent | 73db3490a683a6ecbe98bebe33760c547c113e8d [diff] |
error: Implement RFC-0044 Error Handle (#43) * error: Refactor error handle logic Signed-off-by: Xuanwo <github@xuanwo.io> * Format code Signed-off-by: Xuanwo <github@xuanwo.io> * Return more context Signed-off-by: Xuanwo <github@xuanwo.io> * Implement from for std::io Signed-off-by: Xuanwo <github@xuanwo.io> * Update error handle for std::io Signed-off-by: Xuanwo <github@xuanwo.io> * Update error message Signed-off-by: Xuanwo <github@xuanwo.io> * Fix tracking issue Signed-off-by: Xuanwo <github@xuanwo.io>
Open Data Access Layer that connect the whole world together.
OpenDAL is in alpha stage and has been early adopted by databend. Welcome any feedback at Discussions!
use anyhow::Result; use futures::AsyncReadExt; use opendal::services::fs; use opendal::Operator; #[tokio::main] async fn main() -> Result<()> { let op = Operator::new(fs::Backend::build().root("/tmp").finish().await?); let o = op.object("test_file"); // Write data info file; let w = o.new_writer(); let n = w .write_bytes("Hello, World!".to_string().into_bytes()) .await?; assert_eq!(n, 13); // Read data from file; let mut r = o.new_reader(); let mut buf = vec![]; let n = r.read_to_end(&mut buf).await?; assert_eq!(n, 13); assert_eq!(String::from_utf8_lossy(&buf), "Hello, World!"); // Get file's Metadata let meta = o.stat().await?; assert_eq!(meta.content_length(), 13); // Delete file. o.delete().await?; Ok(()) }
OpenDAL is licensed under Apache 2.0.