fn LinearFifo(comptime T: type, comptime buffer_type: LinearFifoBufferType) type
Fields
allocator: if (buffer_type == .Dynamic) Allocator else void,
buf: if (buffer_type == .Static) [buffer_type.Static]T else []T,
head: usize,
count: usize,
Functions
fn ensureTotalCapacity(self: *Self, size: usize) !void
Ensure that the buffer can fit at least
size
itemsfn ensureUnusedCapacity(self: *Self, size: usize) error{OutOfMemory}!void
Makes sure at least
size
items are unusedfn peekItem(self: Self, offset: usize) T
Returns the item at
offset
. Asserts offset is within bounds.fn pump(self: *Self, src_reader: anytype, dest_writer: anytype) !void
Pump data from a reader into a writer stops when reader returns 0 bytes (EOF) …
Pump data from a reader into a writer stops when reader returns 0 bytes (EOF) Buffer size must be set before calling; a buffer length of 0 is invalid.
fn read(self: *Self, dst: []T) usize
Read data from the fifo into
dst
, returns number of items copied.fn update(self: *Self, count: usize) void
Update the tail location of the buffer (usually follows use of writable/writable…
Update the tail location of the buffer (usually follows use of writable/writableWithSize)
fn writableSlice(self: SliceSelfArg, offset: usize) []T
Returns the first section of writable buffer Note that this may be of length 0
fn writableWithSize(self: *Self, size: usize) ![]T
Returns a writable buffer of at least
size
items, allocating memory as needed….Returns a writable buffer of at least
size
items, allocating memory as needed. Usefifo.update
once you’ve written data to it.fn write(self: *Self, src: []const T) !void
Appends the data in
src
to the fifo. Allocates more memory as necessaryfn writeAssumeCapacity(self: *Self, src: []const T) void
Appends the data in
src
to the fifo. You must have ensured there is enough sp…Appends the data in
src
to the fifo. You must have ensured there is enough space.