pub struct FileWriter { /* private fields */ }Expand description
Type-erased provider write session explicitly 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::Output;
let mut writer = filesystem.open_writer(&Path::parse("/new-report")?, WriteOptions::default())?;
writer.write_fully(b"report")?;
let outcome = writer.commit()?;
assert_eq!(Some(6), outcome.bytes_written());
assert_eq!(WriterState::Committed, writer.state());Implementations§
Source§impl FileWriter
impl FileWriter
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(&mut self) -> Result<WriteOutcome, WriteFailure>
pub fn commit(&mut self) -> Result<WriteOutcome, WriteFailure>
Publishes bytes accepted by this session.
This method borrows rather than consumes the writer. The provider’s typed failure determines whether retry remains safe or only explicit cleanup is available.
§Returns
Actual publication method and atomicity on success.
§Errors
Returns FsErrorKind::InvalidState after commit or abort, or the
provider publication error.
Sourcepub fn abort(&mut self) -> FsResult<WriteAbortOutcome>
pub fn abort(&mut self) -> FsResult<WriteAbortOutcome>
Aborts this writer and releases provider staging resources.
Abort is allowed while open and after every failed commit. Successful cleanup does not imply that an already-published target was rolled back. An indeterminate abort disables automatic drop cleanup so the caller can inspect provider state before choosing a recovery action.
§Returns
Provider-confirmed destination publication state after cleanup.
§Errors
Returns FsErrorKind::InvalidState after commit or a previous abort,
or returns the provider cleanup error while retaining the session.