1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// =============================================================================
// 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>;
}