fn LinearFifo(comptime T: type, comptime buffer_type: LinearFifoBufferType) type

Parameters

T: type,
buffer_type: LinearFifoBufferType,

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 deinit(self: Self) void

No documentation provided.

fn discard(self: *Self, count: usize) void

Discard first count items in the fifo

fn ensureTotalCapacity(self: *Self, size: usize) !void

Ensure that the buffer can fit at least size items

fn ensureUnusedCapacity(self: *Self, size: usize) error{OutOfMemory}!void

Makes sure at least size items are unused

fn 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 readItem(self: *Self) ?T

Read the next item from the fifo

fn readableLength(self: Self) usize

Returns number of items currently in fifo

fn readableSlice(self: SliceSelfArg, offset: usize) []const T

Returns a readable slice from offset

fn readableSliceOfLen(self: *Self, len: usize) []const T

No documentation provided.

fn reader(self: *Self) Reader

No documentation provided.

fn realign(self: *Self) void

No documentation provided.

fn shrink(self: *Self, size: usize) void

Reduce allocated capacity to size.

fn toOwnedSlice(self: *Self) Allocator.Error![]T

No documentation provided.

fn unget(self: *Self, src: []const T) !void

Place data back into the read stream

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 writableLength(self: Self) usize

Returns number of items available in fifo

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. Use fifo.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 necessary

fn 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.

fn writeItem(self: *Self, item: T) !void

Write a single item to the fifo

fn writeItemAssumeCapacity(self: *Self, item: T) void

No documentation provided.

fn writer(self: *Self) Writer

No documentation provided.

Values

Reader
undefined
Writer
undefined