qubit-fs 0.2.2

Provider-neutral synchronous and asynchronous filesystem abstraction for Rust
Documentation
// =============================================================================
//    Copyright (c) 2026 Haixing Hu.
//
//    SPDX-License-Identifier: Apache-2.0
//
//    Licensed under the Apache License, Version 2.0.
// =============================================================================
// facade.
//! Provider-side synchronous writer sessions.

use qubit_io::Output;

use super::SpiWriteFailure;
use crate::error::FsResult;
use crate::metadata::WriteOutcome;
use crate::write::WriteAbortOutcome;

/// Provider writer session.
///
/// # Examples
///
/// ```
/// use qubit_fs::spi::FileWriterSpi;
/// use qubit_io::Output;
///
/// fn accepts_writer<T: FileWriterSpi>() {}
/// fn accepts_output<T: Output<Item = u8>>() {}
/// ```
pub trait FileWriterSpi: Output<Item = u8> + Send {
    /// Publishes accepted bytes.
    ///
    /// # Returns
    /// The confirmed publication outcome.
    ///
    /// # Errors
    /// Returns provider-confirmed failure and recovery state when publication
    /// does not complete successfully.
    fn commit(&mut self) -> Result<WriteOutcome, SpiWriteFailure>;

    /// Releases provider staging resources.
    ///
    /// # Returns
    /// The provider-confirmed destination state after cleanup.
    ///
    /// # Errors
    /// Returns the provider cleanup failure with filesystem context.
    fn abort(&mut self) -> FsResult<WriteAbortOutcome>;
}