vfs/directory/traversal_position.rs
1// Copyright 2019 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5/// Seek position inside a directory. The precise meaning of the Name, Bytes and Index values are
6/// entirely up to an implementation; it could indicate the next entry to be returned or the last
7/// entry returned; the type should be considered to be opaque to the client. There are some
8/// implementations that return entries in alphabetical order, but they are not required to do so.
9/// The Start value indicates the first entry should be returned and the End value indicates no more
10/// entries should be returned. The VFS library will only ever return either `Start` or a value
11/// previously constructed by the implementation, so implementations can assume that other variants
12/// will not be presented to the implementation. As the VFS library evolves, more variants may be
13/// added and so match statements in implementations should have a catch all.
14#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
15pub enum TraversalPosition {
16 /// The first entry in the directory.
17 Start,
18 /// A name of an entry.
19 Name(String),
20 /// Bytes, in any form the implementation desires.
21 Bytes(Box<[u8]>),
22 /// The index of an entry.
23 Index(u64),
24 /// The whole listing was traversed. There is nothing else to return.
25 End,
26}
27
28/// The default value specifies a traversal that is positioned on the very first entry.
29impl Default for TraversalPosition {
30 fn default() -> Self {
31 TraversalPosition::Start
32 }
33}