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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
// facade.
//! Provider-opened asynchronous directory stream envelope.
use super::AsyncDirectoryStreamSession;
use crate::directory::AsyncDirectoryStream;
use crate::directory::ListOptions;
use crate::directory::ListScope;
use crate::metadata::FileSystemLimits;
use crate::path::PathSemantics;
/// An already-open asynchronous directory stream.
///
/// # Examples
///
/// ```rust
/// use qubit_fs::error::FsResult;
/// use qubit_fs::metadata::DirEntry;
/// use qubit_fs::spi::{AsyncDirectoryStreamSession, OpenedAsyncDirectoryStream, SpiFuture};
///
/// struct EmptyStream;
/// impl AsyncDirectoryStreamSession for EmptyStream {
/// fn next_entry_async(&mut self) -> SpiFuture<'_, FsResult<Option<DirEntry>>> {
/// Box::pin(async { Ok(None) })
/// }
/// }
/// let _stream = OpenedAsyncDirectoryStream::new(Box::new(EmptyStream));
/// ```
pub struct OpenedAsyncDirectoryStream {
/// Provider enumeration session awaiting facade validation.
session: Box<dyn AsyncDirectoryStreamSession>,
}
impl OpenedAsyncDirectoryStream {
/// Wraps an opened provider directory-enumeration session.
///
/// # Parameters
/// - `session`: Provider enumeration session.
///
/// # Returns
/// An opened asynchronous stream envelope for facade validation.
#[inline]
#[must_use]
pub fn new(session: Box<dyn AsyncDirectoryStreamSession>) -> Self {
Self { session }
}
/// Transfers the stream into the facade handle.
///
/// # Parameters
/// - `root`: Validated directory root requested by the caller.
/// - `options`: Validated listing behavior.
/// - `provider`: Stable provider identifier used in generated errors.
///
/// # Returns
/// A facade-owned asynchronous directory stream.
#[inline]
pub(crate) fn into_stream(
self,
scope: ListScope,
options: ListOptions,
provider: &str,
path_semantics: PathSemantics,
limits: FileSystemLimits,
) -> crate::error::FsResult<AsyncDirectoryStream> {
AsyncDirectoryStream::new(scope, self.session, options, provider, path_semantics, limits)
}
}