blob: deda81c0245e8f7d3827e55f4b7f41b90cb9cc37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use io;
use endian;
export type op_circle = pos;
export type op_other = void;
export type op = (op_circle| op_other);
export fn send_op(file: io::handle, op: op) (void | io::error) = {
static let buf: [8]u8 = [0...];
const opc = op as op_circle;
endian::leputu32(buf[0..4], opc.0: u32);
endian::leputu32(buf[4..8], opc.1: u32);
io::writeall(file, buf)?;
};
export fn deser_op(bytes: []u8) op = {
assert(len(bytes) == 8, "wrong length somehow");
return (
endian::legetu32(bytes[0..4]): i32,
endian::legetu32(bytes[4..8]): i32,
) : op_circle;
};
|