aboutsummaryrefslogtreecommitdiff
path: root/src/field/id.rs
blob: fa854deee09a39ecdde7b55725fd0c53d85c2aeb (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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#[repr(u16)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ID {
    ErrorText = 100,
    Data = 101,
    UserName = 102,
    UserID = 103,
    UserIconID = 104,
    UserLogin = 105,
    UserPassword = 106,
    ReferenceNumber = 107,
    TransferSize = 108,
    ChatOptions = 109,
    UserAccess = 110,
    UserAlias = 111,
    UserFlags = 112,
    Options = 113,
    ChatID = 114,
    ChatSubject = 115,
    WaitingCount = 116,

    ServerAgreement = 150,
    ServerBanner = 151,
    ServerBannerType = 152,
    ServerBannerUrl = 153,
    NoServerAgreement = 154,

    Version = 160,
    CommunityBannerID = 161,
    ServerName = 162,

    // 200..215
    FileNameWithInfo = 200, // TODO: Parse into a struct! (FileInfo)
    FileName = 201,
    FilePath = 202,
    FileResumeData = 203, // TODO: Parse into a struct! (ResumeData)
    FileXferOptions = 204,
    FileTypeString = 205,
    FileCreatorString = 206,
    FileSize = 207,
    FileCreateDate = 208, // TODO: Parse into a struct! (Date)
    FileModifyDate = 209, // TODO: Parse into a struct! (Date)
    FileComment = 210,
    FileNewName = 211,
    FileNewPath = 212,
    FileType = 213,
    QuotingMessage = 214, // TODO: This is marked as binary, but is basically a string.
    AutomaticResponse = 215,

    FolderItemCount = 220,

    UserNameWithInfo = 300, // TODO: Parse into a struct! (UserInfo)

    NewsCategoryGUID = 319,
    LegacyNewsCategoryListData = 320, // TODO: Parse into a struct! (LegacyNewsCategory)
    NewsArticleListData = 321,        // TODO: Parse into a struct! (NewsArticleList)
    NewsCategoryName = 322,
    NewsCategoryListData = 323, // TODO: Parse into a struct (NewsCategory)

    NewsPath = 325,
    NewsArticleID = 326,
    NewsArticleDataFlavor = 327,
    NewsArticleTitle = 328,
    NewsArticlePoster = 329,
    NewsArticleDate = 330, // TODO: Parse into a struct! (Date)
    NewsArticlePrevArticle = 331,
    NewsArticleNextArticle = 332,
    NewsArticleData = 333,
    NewsArticleFlags = 334,
    NewsArticleParentArticle = 335,
    NewsArticle1stChildArticle = 336,
    NewsArticleRecurseDel = 337,

    // If we receive an unrecognized field ID, we can store it as a raw integer.
    Unknown(u16),
}

impl ID {
    #[must_use]
    pub fn from_u16(id: u16) -> Self {
        use ID::{
            AutomaticResponse, ChatID, ChatOptions, ChatSubject, CommunityBannerID, Data,
            ErrorText, FileComment, FileCreateDate, FileCreatorString, FileModifyDate, FileName,
            FileNameWithInfo, FileNewName, FileNewPath, FilePath, FileResumeData, FileSize,
            FileType, FileTypeString, FileXferOptions, FolderItemCount, LegacyNewsCategoryListData,
            NewsArticle1stChildArticle, NewsArticleData, NewsArticleDataFlavor, NewsArticleDate,
            NewsArticleFlags, NewsArticleID, NewsArticleListData, NewsArticleNextArticle,
            NewsArticleParentArticle, NewsArticlePoster, NewsArticlePrevArticle,
            NewsArticleRecurseDel, NewsArticleTitle, NewsCategoryGUID, NewsCategoryListData,
            NewsCategoryName, NewsPath, NoServerAgreement, Options, QuotingMessage,
            ReferenceNumber, ServerAgreement, ServerBanner, ServerBannerType, ServerBannerUrl,
            ServerName, TransferSize, Unknown, UserAccess, UserAlias, UserFlags, UserID,
            UserIconID, UserLogin, UserName, UserNameWithInfo, UserPassword, Version, WaitingCount,
        };
        match id {
            100 => ErrorText,
            101 => Data,
            102 => UserName,
            103 => UserID,
            104 => UserIconID,
            105 => UserLogin,
            106 => UserPassword,
            107 => ReferenceNumber,
            108 => TransferSize,
            109 => ChatOptions,
            110 => UserAccess,
            111 => UserAlias,
            112 => UserFlags,
            113 => Options,
            114 => ChatID,
            115 => ChatSubject,
            116 => WaitingCount,

            150 => ServerAgreement,
            151 => ServerBanner,
            152 => ServerBannerType,
            153 => ServerBannerUrl,
            154 => NoServerAgreement,
            160 => Version,
            161 => CommunityBannerID,
            162 => ServerName,

            200 => FileNameWithInfo,
            201 => FileName,
            202 => FilePath,
            203 => FileResumeData,
            204 => FileXferOptions,
            205 => FileTypeString,
            206 => FileCreatorString,
            207 => FileSize,
            208 => FileCreateDate,
            209 => FileModifyDate,
            210 => FileComment,
            211 => FileNewName,
            212 => FileNewPath,
            213 => FileType,
            214 => QuotingMessage,
            215 => AutomaticResponse,
            220 => FolderItemCount,

            300 => UserNameWithInfo,
            319 => NewsCategoryGUID,
            320 => LegacyNewsCategoryListData,
            321 => NewsArticleListData,
            322 => NewsCategoryName,
            323 => NewsCategoryListData,
            325 => NewsPath,
            326 => NewsArticleID,
            327 => NewsArticleDataFlavor,
            328 => NewsArticleTitle,
            329 => NewsArticlePoster,
            330 => NewsArticleDate,
            331 => NewsArticlePrevArticle,
            332 => NewsArticleNextArticle,
            333 => NewsArticleData,
            334 => NewsArticleFlags,
            335 => NewsArticleParentArticle,
            336 => NewsArticle1stChildArticle,
            337 => NewsArticleRecurseDel,
            other => Unknown(other),
        }
    }
}