shared/messages/
mod.rs

1// From sending client
2pub mod have_file;
3
4// From recieving client
5pub mod i_have_code;
6
7// From Server
8pub mod ip_for_code;
9pub mod recieving_ip;
10pub mod you_have_file;
11
12pub enum ClientMsg {
13    HaveFile(have_file::HaveFile),
14    IHaveCode(i_have_code::IHaveCode),
15    HolePunch,
16    None,
17}
18
19pub enum ServerMsg {
20    YouHaveFile(you_have_file::YouHaveFile),
21    IpForCode(ip_for_code::IpForCode),
22    Recieving(recieving_ip::RecievingIp),
23}
24pub trait Message {
25    fn to_raw(&self) -> Vec<u8>;
26    fn from_raw(raw: &[u8]) -> Result<Self, &'static str>
27    where
28        Self: Sized;
29}
30
31// have_file: 0
32// i_have_code: 1
33// ip_for_code: 2
34// recieving_ip: 3
35// you_have_file: 4
36// holepunch: 255