From cbe944764439171ec6fc6e39b3e1a7e9fdcec0fc Mon Sep 17 00:00:00 2001 From: Gwo Tzu-Hsing Date: Fri, 25 Oct 2024 21:13:25 +0800 Subject: [PATCH] bump fusio to 0.3.0 & basic docs --- fusio-dispatch/Cargo.toml | 4 ++-- fusio-object-store/Cargo.toml | 4 ++-- fusio-parquet/Cargo.toml | 4 ++-- fusio/Cargo.toml | 3 ++- fusio/src/lib.rs | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/fusio-dispatch/Cargo.toml b/fusio-dispatch/Cargo.toml index c36c4df..baafde5 100644 --- a/fusio-dispatch/Cargo.toml +++ b/fusio-dispatch/Cargo.toml @@ -4,7 +4,7 @@ edition.workspace = true license.workspace = true name = "fusio-dispatch" repository.workspace = true -version = "0.2.0" +version = "0.2.1" [features] aws = ["fusio/aws"] @@ -14,6 +14,6 @@ object_store = ["dep:fusio-object-store", "object_store/aws"] tokio = ["fusio/tokio"] [dependencies] -fusio = { version = "0.2.1", path = "../fusio" } +fusio = { version = "0.3.0", path = "../fusio" } fusio-object-store = { version = "0.2.0", path = "../fusio-object-store", optional = true } object_store = { version = "0.11", optional = true } diff --git a/fusio-object-store/Cargo.toml b/fusio-object-store/Cargo.toml index 213e788..6036c0d 100644 --- a/fusio-object-store/Cargo.toml +++ b/fusio-object-store/Cargo.toml @@ -4,11 +4,11 @@ edition.workspace = true license.workspace = true name = "fusio-object-store" repository.workspace = true -version = "0.2.0" +version = "0.2.1" [dependencies] async-stream = { version = "0.3" } -fusio = { version = "0.2.1", path = "../fusio", features = [ +fusio = { version = "0.3.0", path = "../fusio", features = [ "bytes", "dyn", "object_store", diff --git a/fusio-parquet/Cargo.toml b/fusio-parquet/Cargo.toml index 6ac6624..4208725 100644 --- a/fusio-parquet/Cargo.toml +++ b/fusio-parquet/Cargo.toml @@ -4,11 +4,11 @@ edition.workspace = true license.workspace = true name = "fusio-parquet" repository.workspace = true -version = "0.2.0" +version = "0.2.1" [dependencies] bytes = { workspace = true } -fusio = { version = "0.2.1", path = "../fusio", features = [ +fusio = { version = "0.3.0", path = "../fusio", features = [ "bytes", "dyn", "tokio", diff --git a/fusio/Cargo.toml b/fusio/Cargo.toml index 058cfdb..a1b040d 100644 --- a/fusio/Cargo.toml +++ b/fusio/Cargo.toml @@ -3,8 +3,9 @@ description = "Fusio provides lean, minimal cost abstraction and extensible Read edition.workspace = true license.workspace = true name = "fusio" +readme = "../README.md" repository.workspace = true -version = "0.2.1" +version = "0.3.0" [features] aws = [ diff --git a/fusio/src/lib.rs b/fusio/src/lib.rs index 384de29..eee1e8b 100644 --- a/fusio/src/lib.rs +++ b/fusio/src/lib.rs @@ -17,6 +17,9 @@ pub use dynamic::{DynRead, DynWrite}; pub use error::Error; pub use impls::*; +/// Considering lots of runtimes does not require `Send`for `Future` and `Stream`, +/// we provide a trait to represent the future or stream that may not require `Send`. +/// Users could switch the feature `no-send` at compile-time to disable the `Send` bound for `Future` and `Stream`. /// # Safety /// Do not implement it directly #[cfg(not(feature = "no-send"))] @@ -32,6 +35,7 @@ unsafe impl MaybeSend for T {} #[cfg(feature = "no-send")] unsafe impl MaybeSend for T {} +/// Same as `MaybeSend`, but for `Sync`. /// # Safety /// Do not implement it directly #[cfg(not(feature = "no-send"))] @@ -48,6 +52,21 @@ unsafe impl MaybeSync for T {} unsafe impl MaybeSync for T {} pub trait Write: MaybeSend { + //! The core trait for writing data, + //! it is similar to [`std::io::Write`], but it takes the ownership of the buffer, + //! because completion-based IO requires the buffer to be pinned and should be safe to cancellation. + //! + //! [`Write`] represents "truncate to 0 then append all" semantics, + //! which means the file will be truncated to 0 at first, + //! and each write operation will be appended to the end of the file. + //! + //! Contents are not be garanteed to be written to the file until the [`Write::close`] method is called, + //! [`Write::flush`] may be used to flush the data to the file in some implementations, + //! but not all implementations will do so. + //! + //! Whether the operation is successful or not, the buffer will be returned, + //! [`fusio`] promises that the returned buffer will be the same as the input buffer. + fn write_all( &mut self, buf: B, @@ -59,6 +78,19 @@ pub trait Write: MaybeSend { } pub trait Read: MaybeSend + MaybeSync { + //! The core trait for reading data, + //! it is similar to [`std::io::Read`], + //! but it takes the ownership of the buffer, + //! because completion-based IO requires the buffer to be pinned and should be safe to cancellation. + //! + //! [`Read`] represents "read exactly at" semantics, + //! which means the read operation will start at the specified position. + //! + //! The buffer will be returned with the result, whether the operation is successful or not, + //! [`fusio`] promises that the returned buffer will be the same as the input buffer. + //! + //! If you want sequential reading, try [`SeqRead`]. + fn read_exact_at( &mut self, buf: B,