Skip to main content

qubit_fs/spi/request/
list_request.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8// facade.
9//! Validated directory-listing request.
10
11use crate::directory::ListScope;
12use crate::spi::ResolvedListOptions;
13
14/// Validated listing scope and immutable provider-facing options.
15///
16/// # Examples
17///
18/// ```rust
19/// use qubit_fs::directory::ListOptions;
20/// use qubit_fs::path::Path;
21/// use qubit_fs::spi::ListRequest;
22///
23/// let path = Path::parse("/dir")?;
24/// assert!(std::any::type_name::<ListRequest<'_>>().contains("ListRequest"));
25/// assert_eq!("/dir", path.as_str());
26/// let _ = ListOptions::default();
27/// # Ok::<(), qubit_fs::FsError>(())
28/// ```
29pub struct ListRequest<'a> {
30    /// Caller-selected prefix or configured namespace.
31    scope: &'a ListScope,
32    /// Facade-resolved enumeration behavior.
33    options: ResolvedListOptions,
34}
35
36impl<'a> ListRequest<'a> {
37    /// Creates a request after facade preflight.
38    pub(crate) const fn new(scope: &'a ListScope, options: ResolvedListOptions) -> Self {
39        Self { scope, options }
40    }
41
42    /// Returns the exact caller scope without synthesizing an empty path.
43    #[inline]
44    #[must_use]
45    pub const fn scope(&self) -> &'a ListScope {
46        self.scope
47    }
48
49    /// Returns immutable resolved listing options.
50    #[inline]
51    #[must_use]
52    pub const fn options(&self) -> &ResolvedListOptions {
53        &self.options
54    }
55}