qubit_fs/traits/file_writer.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2026 Haixing Hu.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10//! Writer trait for filesystem resources.
11
12use std::io::Write;
13
14use crate::{
15 FsResult,
16 WriteOutcome,
17};
18
19/// Write handle returned by filesystem implementations.
20pub trait FileWriter: Write + Send {
21 /// Commits the write operation.
22 ///
23 /// # Returns
24 /// Write outcome reported by the provider.
25 ///
26 /// # Errors
27 /// Returns [`crate::FsError`] when the provider cannot commit the write.
28 fn commit(self: Box<Self>) -> FsResult<WriteOutcome>;
29
30 /// Aborts the write operation.
31 ///
32 /// # Errors
33 /// Returns [`crate::FsError`] when the provider cannot abort or clean up
34 /// the write session.
35 fn abort(self: Box<Self>) -> FsResult<()>;
36}