aboutsummaryrefslogtreecommitdiff
path: root/src/field/id.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-02-09 22:44:21 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2025-02-09 22:44:21 +0100
commitc402a8923d2e89607a007f46ee4cde15714d746d (patch)
tree597f0e436cac0ec2dda2eb8437cfb57de6c95a82 /src/field/id.rs
parent48408b9e42eaeeaf0944f9a37f7882ba9ddc7f19 (diff)
Restart with fields module
Diffstat (limited to 'src/field/id.rs')
-rw-r--r--src/field/id.rs149
1 files changed, 149 insertions, 0 deletions
diff --git a/src/field/id.rs b/src/field/id.rs
new file mode 100644
index 0000000..07e02b2
--- /dev/null
+++ b/src/field/id.rs
@@ -0,0 +1,149 @@
+#[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 {
+ pub fn from_u16(id: u16) -> Self {
+ use ID::*;
+ 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),
+ }
+ }
+}