Skip to main content

base_scheduler/
file_stat.rs

1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use super::FileOperation;
5use crate::{Cancellation, FileMetadata, OperationResult};
6use std::future::Future;
7
8/// Query owned metadata for an already-open file resource.
9pub trait FileStat: FileOperation {
10    /// Owned metadata representation chosen by this implementation.
11    type Metadata: FileMetadata;
12
13    /// Query the already-open resource and return owned metadata without moving its cursor. The result is an observation, not an atomic snapshot: await preceding modifications when ordering matters. Path lookup and symlink-following policy belong to resource creation, not this operation.
14    ///
15    /// The future is lazy. Cancellation before dispatch prevents submission; blocking workers check again before execution. Started blocking calls preserve their actual result. Ring cancellation is best effort and waits for original completion. The backend retains the file until access ends, even if the waiting future is dropped.
16    fn file_stat(
17        &self,
18        file: &Self::File,
19        cancellation: &Cancellation,
20    ) -> impl Future<Output = OperationResult<Self::Metadata>> + Send;
21}