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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use tl_proto::{TlRead, TlWrite};

use super::HashRef;

#[derive(Debug, Copy, Clone, TlRead, TlWrite)]
#[tl(boxed)]
pub enum Message<'tl> {
    #[tl(id = 0x7d1bcd1e)]
    Message {
        #[tl(size_hint = 32)]
        id: HashRef<'tl>,
        data: &'tl [u8],
    },
    #[tl(id = 0xa3fc5c03)]
    Answer {
        #[tl(size_hint = 32)]
        query_id: HashRef<'tl>,
        data: &'tl [u8],
    },
    #[tl(id = 0x8a794d69)]
    Query {
        #[tl(size_hint = 32)]
        query_id: HashRef<'tl>,
        max_answer_size: u64,
        timeout: u32,
        data: &'tl [u8],
    },
}

#[derive(Debug, Copy, Clone, TlRead, TlWrite)]
#[tl(boxed)]
pub enum MessagePart<'tl> {
    #[tl(id = 0x185c22cc)]
    MessagePart {
        #[tl(size_hint = 32)]
        transfer_id: HashRef<'tl>,
        fec_type: RaptorQFecType,
        part: u32,
        total_size: u64,
        seqno: u32,
        data: &'tl [u8],
    },
    #[tl(id = 0xf582dc58, size_hint = 40)]
    Confirm {
        transfer_id: HashRef<'tl>,
        part: u32,
        seqno: u32,
    },
    #[tl(id = 0xbc0cb2bf, size_hint = 36)]
    Complete {
        transfer_id: HashRef<'tl>,
        part: u32,
    },
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, TlRead, TlWrite)]
#[tl(boxed, id = 0x8b93a7e0, size_hint = 12)]
pub struct RaptorQFecType {
    pub total_len: u32,
    pub packet_len: u32,
    pub packet_count: u32,
}