···11+//! A simple way to build strings
22+13const std = @import("std");
24const Allocator = std.mem.Allocator;
3546const Self = @This();
5788+/// An error that can occur when using a `StringBuilder`
69pub const Error = Allocator.Error;
710811allocator: Allocator,
+6
src/math.zig
···11+//! Math utilities
22+13const std = @import("std");
24const math = std.math;
3566+/// The type of an angle
47pub const AngleType = enum {
58 Rad,
69 Deg,
710};
8111212+/// An angle, either radians or degrees
913pub fn Angle(comptime T: type) type {
1014 return union(AngleType) {
1115 const Self = @This();
···4145 };
4246}
43474848+/// Create an angle of degrees
4449pub fn angleDeg(v: anytype) Angle(@TypeOf(v)) {
4550 return Angle(@TypeOf(v)).initDegrees(v);
4651}
47525353+/// Create an angle of radians
4854pub fn angleRad(v: anytype) Angle(@TypeOf(v)) {
4955 return Angle(@TypeOf(v)).initRadians(v);
5056}
+4
src/mem.zig
···11+//! Memory utilities
22+13const std = @import("std");
24const mem = std.mem;
3566+/// Split a slice once
47pub fn splitOnce(comptime T: type, haystack: []const T, needle: []const T) ?struct { []const T, []const T } {
58 if (mem.indexOf(T, haystack, needle)) |index| {
69 const lth = haystack[0..index];
···1114 return null;
1215}
13161717+/// Split a slice once using a scalar value
1418pub fn splitOnceScalar(comptime T: type, slice: []const T, delimeter: T) ?struct { []const T, []const T } {
1519 return splitOnce(T, slice, &[_]T{delimeter});
1620}
+4-1
src/packet.zig
···11+//! Generic network packets
22+13const std = @import("std");
24const Io = std.Io;
35const net = std.net;
···79810// TODO: compression
9111212+/// Type used to determine packet sizes
1013pub const PacketSize = u64;
11141515+/// Endian used for packet headers
1216pub const HEADER_ENDIAN = std.builtin.Endian.big;
13171418pub fn Packet(T: type) type {
···4549 /// Deserialize a serialized payload
4650 pub fn deserialize(s: []const u8, allocator: Allocator) !T {
4751 return try zon.parse.fromSlice(T, allocator, s, null, .{});
4848- // return try json.parseFromSlice(T, allocator, s, .{});
4952 }
50535154 /// Send the packet to a writer