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 const fn has_confirmed_publication(&self) -> bool
pub const fn has_confirmed_publication(&self) -> bool
Returns whether this writer session has confirmed publication at any time.
§Returns
true when a commit or abort outcome confirmed publication. false
does not prove that publication did not occur.
Sourcepub const fn cleanup_state(&self) -> RecoveryCleanupState
pub const fn cleanup_state(&self) -> RecoveryCleanupState
Returns the state of explicit provider cleanup for this session.
§Returns
The latest cleanup state, independently of publication history.
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. Only a failure in
WriteFailureState::RetryableNotPublished leaves the writer open for
another explicit commit attempt. WriteFailureState::NotPublished
allows only a valid abort; it does not make commit retryable.
§Returns
A future resolving to the actual publication outcome.
§Errors
The future returns WriteFailure when the provider fails publication
or violates the requested atomicity, durability, or byte-count
contract. The failure state records what is known about publication.
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. Every Ok confirms cleanup;
Indeterminate means only that destination publication is unknown.
§Errors
The future returns an FsError when provider cleanup fails. The error
includes the operation context available from the facade.
Trait Implementations§
Source§impl AsyncOutput for AsyncFileWriter
impl AsyncOutput for AsyncFileWriter
Source§fn is_buffered(&self) -> bool
fn is_buffered(&self) -> bool
Reports whether the provider session buffers output before flushing.
Source§unsafe fn poll_write_unchecked(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
input: &[u8],
index: usize,
count: usize,
) -> Poll<IoResult<usize>>
unsafe fn poll_write_unchecked( self: Pin<&mut Self>, cx: &mut Context<'_>, input: &[u8], index: usize, count: usize, ) -> Poll<IoResult<usize>>
Polls a provider write while tracking accepted bytes and uncertainty.
§Safety
index and count must identify a valid range within input.
§Parameters
cx: Task context used to poll the provider session.input: Input bytes containing the requested range.index: Starting offset of the requested input range.count: Maximum number of bytes requested from the provider.
Source§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<IoResult<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<IoResult<()>>
Polls the provider flush and marks the writer indeterminate on failure.
§Parameters
cx: Task context used to poll the provider session.