diff options
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/schema.d.ts | 2 | ||||
| -rw-r--r-- | src/api/schema.js | 8 | ||||
| -rw-r--r-- | src/api/schema.peechy | 5 | ||||
| -rw-r--r-- | src/api/schema.zig | 21 |
4 files changed, 21 insertions, 15 deletions
diff --git a/src/api/schema.d.ts b/src/api/schema.d.ts index 43c8bc47f..902c376ff 100644 --- a/src/api/schema.d.ts +++ b/src/api/schema.d.ts @@ -314,7 +314,7 @@ type uint32 = number; loader: Loader; module_path: alphanumeric; log: Log; - bytes: Uint8Array; + blob_length: uint32; } export interface WebsocketMessageBuildFailure { diff --git a/src/api/schema.js b/src/api/schema.js index 71fde7436..9fdd5e73d 100644 --- a/src/api/schema.js +++ b/src/api/schema.js @@ -1393,7 +1393,7 @@ function decodeWebsocketMessageBuildSuccess(bb) { result["loader"] = Loader[bb.readByte()]; result["module_path"] = bb.readAlphanumeric(); result["log"] = decodeLog(bb); - result["bytes"] = bb.readByteArray(); + result["blob_length"] = bb.readUint32(); return result; } @@ -1436,11 +1436,11 @@ bb.writeByte(encoded); throw new Error("Missing required field \"log\""); } - var value = message["bytes"]; + var value = message["blob_length"]; if (value != null) { - bb.writeByteArray(value); + bb.writeUint32(value); } else { - throw new Error("Missing required field \"bytes\""); + throw new Error("Missing required field \"blob_length\""); } } diff --git a/src/api/schema.peechy b/src/api/schema.peechy index 6fa6912ef..48387906b 100644 --- a/src/api/schema.peechy +++ b/src/api/schema.peechy @@ -290,9 +290,12 @@ struct WebsocketMessageBuildSuccess { alphanumeric module_path; Log log; - byte[] bytes; + + // This is the length of the blob that immediately follows this message. + uint32 blob_length; } + struct WebsocketMessageBuildFailure { uint32 id; uint32 from_timestamp; diff --git a/src/api/schema.zig b/src/api/schema.zig index 106815345..94c5bb643 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -206,13 +206,16 @@ pub fn Writer(comptime WritableStream: type) type { pub fn writeValue(this: *Self, slice: anytype) !void { switch (@TypeOf(slice)) { - []u8, + []u8, []const u8 => { + try this.writeArray(u8, slice); + }, + []u16, []u32, []i16, []i32, []i8, - []const u8, + []const u16, []const u32, []const i16, @@ -276,7 +279,7 @@ pub fn Writer(comptime WritableStream: type) type { }; } -pub const ByteWriter = Writer(std.io.FixedBufferStream([]u8)); +pub const ByteWriter = Writer(*std.io.FixedBufferStream([]u8)); pub const FileWriter = Writer(std.fs.File); pub const Api = struct { @@ -1413,8 +1416,8 @@ pub const Api = struct { /// log log: Log, - /// bytes - bytes: []const u8, + /// blob_length + blob_length: u32 = 0, pub fn decode(reader: anytype) anyerror!WebsocketMessageBuildSuccess { var this = std.mem.zeroes(WebsocketMessageBuildSuccess); @@ -1424,7 +1427,7 @@ pub const Api = struct { this.loader = try reader.readValue(Loader); this.module_path = try reader.readValue([]const u8); this.log = try reader.readValue(Log); - this.bytes = try reader.readArray(u8); + this.blob_length = try reader.readValue(u32); return this; } @@ -1432,9 +1435,9 @@ pub const Api = struct { try writer.writeInt(this.id); try writer.writeInt(this.from_timestamp); try writer.writeEnum(this.loader); - try writer.writeValue(this.module_path); + try writer.writeArray(u8, this.module_path); try writer.writeValue(this.log); - try writer.writeArray(u8, this.bytes); + try writer.writeInt(this.blob_length); } }; @@ -1469,7 +1472,7 @@ pub const Api = struct { try writer.writeInt(this.id); try writer.writeInt(this.from_timestamp); try writer.writeEnum(this.loader); - try writer.writeValue(this.module_path); + try writer.writeArray(u8, this.module_path); try writer.writeValue(this.log); } }; |
