Skip to documentation
SLOP

tiny.quic.connection.stream.ring

Reference tiny.quic connection stream ring

Defined in connection.stream.

API (2)

Actions

Public operations.

No direct callersNo direct callsconnection.streamring
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callsconnection.stream.Receivereadtest sourcelib.quic.src.connection.stream.ringtest: ring copies wrap once at the bu...connection.stream.ringread
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsconnection.stream.Receivereceivetest sourcelib.quic.src.connection.stream.ringtest: ring copies wrap once at the bu...connection.stream.Sendwriteconnection.stream.ringwrite
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/quic/src/connection/stream/ring.zig

zig
const std = @import("std");/// Copies the input into the buffer from `index` on, carrying on at the buffer start where it runs/// off the end. The index sits inside the buffer and the input fits. The sending and receiving/// parts both buffer stream bytes through this write.pub fn write(ring: []u8, index: usize, input: []const u8) void {    std.debug.assert(index < ring.len);    std.debug.assert(input.len <= ring.len);    const first = @min(input.len, ring.len - index);    @memcpy(ring[index..][0..first], input[0..first]);    @memcpy(ring[0 .. input.len - first], input[first..]);}/// Fills the output from the buffer from `index` on, carrying on at the buffer start where it runs/// off the end. The index sits inside the buffer and the output fits. The receiving part hands an/// application its bytes through this read.pub fn read(ring: []const u8, index: usize, output: []u8) void {    std.debug.assert(index < ring.len);    std.debug.assert(output.len <= ring.len);    const first = @min(output.len, ring.len - index);    @memcpy(output[0..first], ring[index..][0..first]);    @memcpy(output[first..], ring[0 .. output.len - first]);}test "ring copies wrap once at the buffer end" {    var ring: [4]u8 = @splat(0);    write(&ring, 3, "abc");    try std.testing.expectEqualSlices(u8, &.{ 'b', 'c', 0, 'a' }, &ring);    var output: [3]u8 = undefined;    read(&ring, 3, &output);    try std.testing.expectEqualStrings("abc", &output);    write(&ring, 0, "wxyz");    try std.testing.expectEqualStrings("wxyz", &ring);}

Source: lib/quic/src/connection/stream/root.zig:7

zig
pub const ring = @import("ring.zig");

Audit

Definitions3
Public names3
Members0
Version26.7.0
Revisiondaab053ee433