/// Child process for the remoting round-trip test. /// Reads one framed CBOR message from stdin, expects ["ping"], /// and replies with ["pong"] on stdout. const std = @import("std"); const cbor = @import("cbor"); const framing = @import("framing"); pub fn main() !void { var acc: framing.Accumulator = .{}; var read_buf: [4096]u8 = undefined; const frame = while (true) { const n = try std.fs.File.stdin().read(&read_buf); if (n == 0) return error.UnexpectedEof; if (acc.feed(read_buf[0..n])) |f| break f; }; if (!try cbor.match(frame, .{"ping"})) return error.UnexpectedMessage; var msg_buf: [64]u8 = undefined; var stream: std.Io.Writer = .fixed(&msg_buf); try cbor.writeValue(&stream, .{"pong"}); try framing.write_frame(std.fs.File.stdout(), stream.buffered()); }