Skip to main content

rns_hooks/
wire.rs

1/// Wire-format enum mirroring `TransportAction` with raw primitives.
2///
3/// Uses `u64` for interface IDs and `[u8; N]` for hashes so that `rns-hooks`
4/// has zero dependency on `rns-core`. Conversions happen at call sites.
5///
6/// Data fields use owned `Vec<u8>` — the data is copied from WASM linear memory
7/// when the action is parsed, so ActionWire values remain valid after the store
8/// is dropped.
9#[derive(Debug, Clone)]
10pub enum ActionWire {
11    SendOnInterface {
12        interface: u64,
13        raw: Vec<u8>,
14    },
15    BroadcastOnAllInterfaces {
16        raw: Vec<u8>,
17        exclude: u64,
18        has_exclude: u8,
19    },
20    DeliverLocal {
21        destination_hash: [u8; 16],
22        raw: Vec<u8>,
23        packet_hash: [u8; 32],
24        receiving_interface: u64,
25    },
26    AnnounceReceived {
27        destination_hash: [u8; 16],
28        identity_hash: [u8; 16],
29        public_key: [u8; 64],
30        name_hash: [u8; 10],
31        random_hash: [u8; 10],
32        app_data: Option<Vec<u8>>,
33        hops: u8,
34        receiving_interface: u64,
35    },
36    PathUpdated {
37        destination_hash: [u8; 16],
38        hops: u8,
39        next_hop: [u8; 16],
40        interface: u64,
41    },
42    ForwardToLocalClients {
43        raw: Vec<u8>,
44        exclude: u64,
45        has_exclude: u8,
46    },
47    ForwardPlainBroadcast {
48        raw: Vec<u8>,
49        to_local: u8,
50        exclude: u64,
51        has_exclude: u8,
52    },
53    CacheAnnounce {
54        packet_hash: [u8; 32],
55        raw: Vec<u8>,
56    },
57    TunnelSynthesize {
58        interface: u64,
59        data: Vec<u8>,
60        dest_hash: [u8; 16],
61    },
62    TunnelEstablished {
63        tunnel_id: [u8; 32],
64        interface: u64,
65    },
66}