Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Struct

Iterator

Public Struct
std.Io.Dir.Iterator
pub const Iterator = struct

This API is designed for convenience rather than performance:

  • It chooses a buffer size rather than allowing the user to provide one.
  • It is movable by only requesting one Entry at a time from the Io implementation rather than doing batch operations.

Still, it will do a decent job of minimizing syscall overhead. For a lower level abstraction, see Reader. For a higher level abstraction, see Walker.

Fields

reader: Reader
reader_buffer: [reader_buffer_len]u8

Values

Functions

pub fn init(dir: Dir, reader_state: Reader.State) Iterator
pub fn next(it: *Iterator, io: Io) Error!?Entry

File

Io/Dir.zig:180
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
pub const Iterator = struct {
    reader: Reader,
    reader_buffer: [reader_buffer_len]u8 align(@alignOf(usize)),

    pub const reader_buffer_len = 2048;

    comptime {
        assert(reader_buffer_len >= Reader.min_buffer_len);
    }

    pub const Error = Reader.Error;

    pub fn init(dir: Dir, reader_state: Reader.State) Iterator {
        return .{
            .reader = .{
                .dir = dir,
                .state = reader_state,
                .index = 0,
                .end = 0,
                .buffer = undefined,
            },
            .reader_buffer = undefined,
        };
    }

    pub fn next(it: *Iterator, io: Io) Error!?Entry {
        it.reader.buffer = &it.reader_buffer;
        return it.reader.next(io);
    }
}