base_scheduler/file_close.rs
1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use super::FileOperation;
5use std::future::Future;
6
7/// Close exclusively owned file resources with completion or admission-only semantics.
8pub trait FileClose: FileOperation {
9 /// Consume an exclusively owned handle, wait for bounded admission and OS close completion, and report admission or close errors. This future is lazy and takes no cancellation token. Close does not synchronize file contents and is never retried after an error.
10 ///
11 /// Finish all operations using the file first. Requesting cancellation or dropping an operation future alone does not establish that backend access has ended. Once admitted, close runs even if this future is dropped. Before admission, dropping the future releases the handle through ordinary destruction.
12 ///
13 /// # Panics
14 /// Backends may panic if an abandoned operation still retains the file. Close never interrupts or joins other operations.
15 fn file_close(&self, file: Self::File) -> impl Future<Output = std::io::Result<()>> + Send;
16
17 /// Consume an exclusively owned handle and wait only for bounded admission. The scheduler then owns completion even if this future is dropped. Errors report admission failure, not OS close failure; await `file_close` when execution errors matter.
18 ///
19 /// The ownership, laziness, and outstanding-operation preconditions are the same as [`FileClose::file_close`]. Graceful scheduler shutdown drains accepted close jobs.
20 fn file_close_submit(
21 &self,
22 file: Self::File,
23 ) -> impl Future<Output = std::io::Result<()>> + Send;
24}