1 // Copyright 2018 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 #pragma once
6 
7 #include <stdbool.h>
8 #include <stdint.h>
9 
10 #include <blobfs/format.h>
11 #include <zircon/types.h>
12 
13 namespace blobfs {
14 
15 // Interface for a class which may be used to iterate over a collection of extents.
16 class ExtentIterator {
17 public:
18     virtual ~ExtentIterator() = default;
19 
20     // Returns true if there are no more extents to be consumed.
21     virtual bool Done() const = 0;
22 
23     // On success, returns ZX_OK and the next extent in |out|.
24     virtual zx_status_t Next(const Extent** out) = 0;
25 
26     // Returns the number of blocks iterated past already. Updated on each
27     // call to |Next|.
28     virtual uint64_t BlockIndex() const = 0;
29 };
30 
31 // Interface to look up nodes.
32 class NodeFinder {
33 public:
34     virtual ~NodeFinder() = default;
35 
36     // Returns a pointer to the requested node.
37     //
38     // TODO(smklein): Return a zx_status_t to allow for invalid |ino| values.
39     virtual Inode* GetNode(uint32_t node_index) = 0;
40 };
41 
42 } // namespace blobfs
43