This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch refactor-writer
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/refactor-writer by this push:
new 3e9da146 Fix unit tests
3e9da146 is described below
commit 3e9da1469a40968e6fcf0012f555e6652bdf76d9
Author: Xuanwo <[email protected]>
AuthorDate: Wed Apr 19 17:47:55 2023 +0800
Fix unit tests
Signed-off-by: Xuanwo <[email protected]>
---
core/src/types/operator/blocking_operator.rs | 4 ++--
core/src/types/operator/operator.rs | 8 ++++----
core/src/types/writer.rs | 7 ++++++-
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/core/src/types/operator/blocking_operator.rs
b/core/src/types/operator/blocking_operator.rs
index a985474d..6b7a48df 100644
--- a/core/src/types/operator/blocking_operator.rs
+++ b/core/src/types/operator/blocking_operator.rs
@@ -626,8 +626,8 @@ impl BlockingOperator {
///
/// # fn test(op: BlockingOperator) -> Result<()> {
/// let mut w = op.writer("path/to/file")?;
- /// w.append(vec![0; 4096])?;
- /// w.append(vec![1; 4096])?;
+ /// w.write(vec![0; 4096])?;
+ /// w.write(vec![1; 4096])?;
/// w.close()?;
/// # Ok(())
/// # }
diff --git a/core/src/types/operator/operator.rs
b/core/src/types/operator/operator.rs
index 0d46ebad..ad24a542 100644
--- a/core/src/types/operator/operator.rs
+++ b/core/src/types/operator/operator.rs
@@ -775,8 +775,8 @@ impl Operator {
/// # #[tokio::main]
/// # async fn test(op: Operator) -> Result<()> {
/// let mut w = op.writer("path/to/file").await?;
- /// w.append(vec![0; 4096]).await?;
- /// w.append(vec![1; 4096]).await?;
+ /// w.write(vec![0; 4096]).await?;
+ /// w.write(vec![1; 4096]).await?;
/// w.close().await?;
/// # Ok(())
/// # }
@@ -805,8 +805,8 @@ impl Operator {
/// # async fn test(op: Operator) -> Result<()> {
/// let args =
OpWrite::new().with_content_type("application/octet-stream");
/// let mut w = op.writer_with("path/to/file", args).await?;
- /// w.append(vec![0; 4096]).await?;
- /// w.append(vec![1; 4096]).await?;
+ /// w.write(vec![0; 4096]).await?;
+ /// w.write(vec![1; 4096]).await?;
/// w.close().await?;
/// # Ok(())
/// # }
diff --git a/core/src/types/writer.rs b/core/src/types/writer.rs
index 49cc397e..321988b9 100644
--- a/core/src/types/writer.rs
+++ b/core/src/types/writer.rs
@@ -66,7 +66,7 @@ impl Writer {
w.write(bs.into()).await
} else {
unreachable!(
- "writer state invalid while abort, expect Idle, actual {}",
+ "writer state invalid while write, expect Idle, actual {}",
self.state
);
}
@@ -266,6 +266,11 @@ impl BlockingWriter {
Ok(BlockingWriter { inner: w })
}
+ /// Write into inner writer.
+ pub fn write(&mut self, bs: impl Into<Bytes>) -> Result<()> {
+ self.inner.write(bs.into())
+ }
+
/// Close the writer and make sure all data have been stored.
pub fn close(&mut self) -> Result<()> {
self.inner.close()