pub struct Writer { /* private fields */ }Available on crate feature
blocking only.Expand description
BlockingWriter is designed to write data into given path in an blocking manner.
Implementations§
Source§impl Writer
impl Writer
Sourcepub fn write(&mut self, bs: impl Into<Buffer>) -> Result<()>
pub fn write(&mut self, bs: impl Into<Buffer>) -> Result<()>
Write Buffer into writer.
This operation will write all data in given buffer into writer.
§Examples
use bytes::Bytes;
use opendal_core::blocking;
use opendal_core::blocking::Operator;
use opendal_core::Result;
fn test(op: blocking::Operator) -> Result<()> {
let mut w = op.writer("hello.txt")?;
// Buffer can be created from continues bytes.
w.write("hello, world")?;
// Buffer can also be created from non-continues bytes.
w.write(vec![Bytes::from("hello,"), Bytes::from("world!")])?;
// Make sure file has been written completely.
w.close()?;
Ok(())
}Sourcepub fn close(&mut self) -> Result<Metadata>
pub fn close(&mut self) -> Result<Metadata>
Close the writer and make sure all data have been committed.
§Notes
Close should only be called when the writer is not closed or aborted, otherwise an unexpected error could be returned.
Sourcepub fn into_std_write(self) -> StdWriter ⓘ
pub fn into_std_write(self) -> StdWriter ⓘ
Convert writer into StdWriter which implements std::io::Write,
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Writer
impl !RefUnwindSafe for Writer
impl Send for Writer
impl Sync for Writer
impl Unpin for Writer
impl !UnwindSafe for Writer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more