summaryrefslogtreecommitdiff
path: root/abi/wire.zig
diff options
context:
space:
mode:
Diffstat (limited to 'abi/wire.zig')
-rw-r--r--abi/wire.zig38
1 files changed, 14 insertions, 24 deletions
diff --git a/abi/wire.zig b/abi/wire.zig
index f87131bf..8f7a7bdb 100644
--- a/abi/wire.zig
+++ b/abi/wire.zig
@@ -10,6 +10,11 @@ const pardes = @import("core");
const config = @import("pardes_options");
const build_info = @import("build_info");
+/// 30: the terminals' one road: the screen-state messages are retired (a
+/// replica's `screen_ack`, 0x04, and the session's `screen`, 0x06: gaps),
+/// a welcome says no road (its `bytes` byte gone), and a pane's
+/// `term_images` and its tape site leave the dump (each side's emulator
+/// answers; a terminal's digest holds whether it has an image);
/// 29: a session's terminals reach its clients as the pty's bytes in its
/// units, each client's emulator its own; a welcome says the road (`bytes`;
/// screen state under PARDES_TERM_SCREEN), which the client loads its dump
@@ -54,7 +59,7 @@ const build_info = @import("build_info");
/// part B); 14: the hello names a session and
/// carries the semantics hash, and a ping is answered (phase 5's
/// groundwork); 13: the frames went (phase 3).
-pub const version: u16 = 29;
+pub const version: u16 = 30;
/// The terminal's build and the window's step alike (`semantics`).
const family = switch (config.platform) {
@@ -113,9 +118,6 @@ pub const ClientTag = enum(u8) {
hello = 0x01,
bye = 0x02,
ping = 0x03,
- /// A replica's word about a terminal's state (core/term/screen_state.zig): the
- /// delta it holds, or rows it asks for. Opaque here.
- screen_ack = 0x04,
/// What is the session's digest, in stream order (a replica checks
/// itself against it once quiet).
check = 0x05,
@@ -201,9 +203,6 @@ pub const ServerTag = enum(u8) {
/// A unit of the authority's stream (core/replica.zig): its origin, seq,
/// clocks and tape.
unit = 0x05,
- /// A terminal's delta, or rows asked for (core/term/screen_state.zig), applied
- /// before the next unit. Opaque here.
- screen = 0x06,
/// The session's digest (u64le), after every unit before it.
check = 0x07,
/// Part of the join's list of blobs, to a far client: each one's place
@@ -227,12 +226,11 @@ pub const ServerMsg = union(ServerTag) {
/// dump that follows is, and the session's offset from UTC (a replica
/// guesses the session's time of day). A far client is told how many
/// blobs the dump holds (`blobs`).
- welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: pardes.Pardes.View.Id = .at(0), dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0, semantics: u64 = 0, bytes: bool = false, blobs: u32 = 0 },
+ welcome: struct { pid: u32, session: []const u8, client: u16 = 0, view: pardes.Pardes.View.Id = .at(0), dump_len: u64 = 0, gmtoff: i32 = 0, digest: u64 = 0, semantics: u64 = 0, blobs: u32 = 0 },
refused: []const u8,
pong: u64,
dump: []const u8,
unit: []const u8,
- screen: []const u8,
check: u64,
blobs: []const u8,
zstd: []const u8,
@@ -263,14 +261,12 @@ pub fn decodeServer(tag: u8, payload: []const u8) Error!ServerMsg {
.gmtoff = try r.takeInt(i32, .little),
.digest = try r.takeInt(u64, .little),
.semantics = try r.takeInt(u64, .little),
- .bytes = try r.takeByte() != 0,
.blobs = try r.takeInt(u32, .little),
} },
.refused => .{ .refused = try r.take(try r.takeInt(u16, .little)) },
.pong => .{ .pong = try r.takeInt(u64, .little) },
.dump => return .{ .dump = payload },
.unit => return .{ .unit = payload },
- .screen => return .{ .screen = payload },
.check => .{ .check = try r.takeInt(u64, .little) },
.blobs => return .{ .blobs = payload },
.zstd => return .{ .zstd = payload },
@@ -295,12 +291,11 @@ pub fn encodeServer(out: []u8, msg: ServerMsg) Error![]const u8 {
try w.writeInt(i32, h.gmtoff, .little);
try w.writeInt(u64, h.digest, .little);
try w.writeInt(u64, h.semantics, .little);
- try w.writeByte(@intFromBool(h.bytes));
try w.writeInt(u32, h.blobs, .little);
},
.refused => |words| try putSlice16(&w, words),
.pong => |v| try w.writeInt(u64, v, .little),
- .dump, .unit, .screen, .blobs, .zstd, .blob => |bytes| try w.writeAll(bytes),
+ .dump, .unit, .blobs, .zstd, .blob => |bytes| try w.writeAll(bytes),
.check => |v| try w.writeInt(u64, v, .little),
.ended => |code| try w.writeByte(code),
.left => |name| try putSlice16(&w, name),
@@ -327,7 +322,6 @@ pub const ClientMsg = union(enum) {
bye: struct { again: bool = false, close: bool = false },
/// A round trip's probe, answered `pong` with the same value.
ping: u64,
- screen_ack: []const u8,
check,
far: bool,
want: []const u8,
@@ -545,7 +539,7 @@ pub fn encodeClient(out: []u8, msg: ClientMsg) Error![]const u8 {
// 0 it leaves, 1 it joins again, 2 its window was closed.
.bye => |b| try w.writeByte(if (b.close) 2 else @intFromBool(b.again)),
.ping, .boot => |v| try w.writeInt(u64, v, .little),
- .screen_ack, .want => |bytes| try w.writeAll(bytes),
+ .want => |bytes| try w.writeAll(bytes),
.check => {},
.far => |far| try w.writeByte(@intFromBool(far)),
.stamp => |s| for (s) |v| try w.writeInt(i64, v, .little),
@@ -620,7 +614,6 @@ pub fn decodeClient(tag: u8, payload: []const u8) Error!ClientMsg {
else => return error.BadValue,
} },
.ping => .{ .ping = try r.takeInt(u64, .little) },
- .screen_ack => return .{ .screen_ack = payload },
.check => .check,
.far => .{ .far = try getBool(&r) },
.want => return .{ .want = payload },
@@ -683,7 +676,7 @@ pub fn clientBound(msg: ClientMsg) usize {
return msg_slack + switch (msg) {
.hello => |h| h.session.len,
.bye, .ping, .check, .far, .stamp, .boot => 0,
- .screen_ack, .want => |bytes| bytes.len,
+ .want => |bytes| bytes.len,
.event => |ev| switch (ev) {
// Its hits' places (14 bytes each) past the slack.
.mouse => 32,
@@ -739,14 +732,13 @@ test "detached wire: every Event variant round-trips" {
try testing.expectEqual(@as(u64, 0xfeed_beef_0000_0001), (try roundClient(&buf, .{ .ping = 0xfeed_beef_0000_0001 })).ping);
{
// The other way: framed the same, its tag the ServerTag's number.
- const bytes = try encodeServer(&buf, .{ .welcome = .{ .pid = 42, .session = "work", .bytes = true } });
+ const bytes = try encodeServer(&buf, .{ .welcome = .{ .pid = 42, .session = "work" } });
const f = (try framed(bytes)).?;
try testing.expectEqual(@as(u8, 0x01), f.tag);
- try testing.expectEqualSlices(u8, &.{ 42, 0, 0, 0, 4, 0, 'w', 'o', 'r', 'k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, f.payload);
+ try testing.expectEqualSlices(u8, &.{ 42, 0, 0, 0, 4, 0, 'w', 'o', 'r', 'k', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, f.payload);
const back = (try decodeServer(f.tag, f.payload)).welcome;
try testing.expectEqualStrings("work", back.session);
try testing.expectEqual(@as(u32, 42), back.pid);
- try testing.expect(back.bytes);
try testing.expectEqual(@as(u8, 0x03), (try framed(try encodeServer(&buf, .{ .pong = 7 }))).?.tag);
}
@@ -804,10 +796,8 @@ test "detached wire: a session is never told to do a frontend's remembering" {
// them, and the machine that reports them is the one already holding the
// core.
const allowed = [_][]const u8{
- // Who this connection is, its round trip, and that it is finished,
- // and which terminal state its replica holds (a protocol's word,
- // as a ping is).
- "hello", "bye", "ping", "screen_ack", "check",
+ // Who this connection is, its round trip, and that it is finished.
+ "hello", "bye", "ping", "check",
// ...and how far it is, and which of the join's blobs it lacks.
"far", "want",
// ...and the digest of the core it made itself (a pair's).