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>
8 files changed
tree: 6624f8de18ed23697307996f27d7c31f237476fb
  1. .github/
  2. benches/
  3. docs/
  4. examples/
  5. src/
  6. tests/
  7. .gitignore
  8. .licenserc.yaml
  9. Cargo.toml
  10. CHANGELOG.md
  11. LICENSE
  12. README.md
  13. rust-toolchain.toml
  14. rustfmt.toml
README.md

OpenDAL

Open Data Access Layer that connect the whole world together.

Status

OpenDAL is in alpha stage and has been early adopted by databend. Welcome any feedback at Discussions!

Quickstart

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(())
}

License

OpenDAL is licensed under Apache 2.0.