pub struct AsyncFileWriter { /* private fields */ }Expand description
Type-erased asynchronous provider write session associated with a file.
§Examples
This example uses an isolated in-memory provider fixture.
use qubit_fs::Path;
use qubit_fs::write::WriteOptions;
use qubit_fs::write::WriterState;
use qubit_io::AsyncOutput;
let mut writer = filesystem.open_writer(&Path::parse("/report")?, WriteOptions::default()).await?;
writer.write_fully_async(b"bytes").await?;
writer.commit_async().await?;
assert_eq!(WriterState::Committed, writer.state());Implementations§
Source§impl AsyncFileWriter
impl AsyncFileWriter
Sourcepub fn info(&self) -> &OpenedFileInfo
pub fn info(&self) -> &OpenedFileInfo
Returns the fixed identity and open-time metadata snapshot.
§Returns
Information captured when the writer was opened.
Sourcepub const fn state(&self) -> WriterState
pub const fn state(&self) -> WriterState
Sourcepub fn commit_async(
&mut self,
) -> SpiFuture<'_, Result<WriteOutcome, WriteFailure>>
pub fn commit_async( &mut self, ) -> SpiFuture<'_, Result<WriteOutcome, WriteFailure>>
Asynchronously publishes bytes accepted by this session.
A definite failure retains the open session for retry or abort. An
indeterminate failure retains the session and changes its observable
state to WriterState::Indeterminate. Once the returned future has
been polled, dropping it before completion also makes the writer
indeterminate because publication may already have started. Dropping an
unpolled future leaves the writer open.
§Returns
A future resolving to the actual publication outcome.
Sourcepub fn abort_async(&mut self) -> SpiFuture<'_, FsResult<WriteAbortOutcome>>
pub fn abort_async(&mut self) -> SpiFuture<'_, FsResult<WriteAbortOutcome>>
Asynchronously aborts this session and its provider staging resources.
Once polled, cancellation before completion leaves the writer indeterminate. A definite provider failure restores the state from which abort was started; an indeterminate provider failure does not. Automatic drop cancellation is disabled for an indeterminate writer.
§Returns
A future resolving to the provider-confirmed destination publication state after cleanup.