Skip to main content

AsyncFileWriter

Struct AsyncFileWriter 

Source
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

Source

pub fn info(&self) -> &OpenedFileInfo

Returns the fixed identity and open-time metadata snapshot.

§Returns

Information captured when the writer was opened.

Source

pub const fn state(&self) -> WriterState

Returns the current lifecycle state.

§Returns

Current writer state.

Source

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.

Source

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.

Trait Implementations§

Source§

impl AsyncOutput for AsyncFileWriter

Source§

type Item = u8

The item type written to this output.
Source§

fn is_buffered(&self) -> bool

Returns whether this output already buffers items internally. Read more
Source§

unsafe fn poll_write_unchecked( self: Pin<&mut Self>, cx: &mut Context<'_>, input: &[u8], index: usize, count: usize, ) -> Poll<IoResult<usize>>

Polls an indexed write without checking the source range. Read more
Source§

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<IoResult<()>>

Polls the flushing of internally buffered items. Read more
Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, input: &[Self::Item], ) -> Poll<Result<usize, Error>>

Polls one write from the full source slice. Read more
Source§

fn write_async<'a>( &'a mut self, input: &'a [Self::Item], ) -> WriteFuture<'a, Self> ⓘ
where Self: Sized + Unpin,

Creates a future that performs one asynchronous write operation. Read more
Source§

fn write_fully_async<'a>( &'a mut self, input: &'a [Self::Item], ) -> WriteFullyFuture<'a, Self> ⓘ
where Self: Sized + Unpin,

Creates a future that writes the entire source slice. Read more
Source§

fn flush_async(&mut self) -> FlushFuture<'_, Self> ⓘ
where Self: Sized + Unpin,

Creates a future that flushes internally buffered items. Read more
Source§

impl Debug for AsyncFileWriter

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl Drop for AsyncFileWriter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.