aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-02-09 23:19:28 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2025-02-09 23:19:28 +0100
commitf2bf6c9924752e5e1f747cecd17f3929186e7d42 (patch)
tree0df3eb40cdd1ffcb18bf1faa7f8f6791804a47cd /src
parentcf94c0cc512994ca847f1c376e86735c54a6ee59 (diff)
Correct documentation
Diffstat (limited to 'src')
-rw-r--r--src/field/mod.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/field/mod.rs b/src/field/mod.rs
index a746ece..7168e10 100644
--- a/src/field/mod.rs
+++ b/src/field/mod.rs
@@ -16,11 +16,6 @@ pub enum Error {
/// 1) "integer" (16-bit or 32-bit, determined by magnitude)
/// 2) "string" (ASCII)
/// 3) "binary"
-///
-/// Internally, we can unify them into:
-/// - Integer(u32)
-/// - String(String)
-/// - Binary(Vec<u8>)
#[derive(Debug, Clone)]
pub enum Value {
Integer(u32),
@@ -35,11 +30,10 @@ pub struct Field {
pub value: Value,
}
-/// Parse the field data into the correct `Value` type based on the `field_id`.
-/// The spec says:
-/// - Some field IDs are definitely “integer” (e.g. user ID).
-/// - Some are definitely “string” (e.g. user name).
-/// - Others are “binary” (which might contain sub-structures).
+/// Parse the field data into the correct `Value` type based on the `id`.
+///
+/// # Errors
+/// If an Int can't be parsed, it'll return an InvalidInteger error.
#[must_use]
pub fn parse_field_value(id: ID, data: &[u8]) -> Result<Value, Error> {
use Value::{Binary, Integer, Text};
@@ -58,8 +52,6 @@ pub fn parse_field_value(id: ID, data: &[u8]) -> Result<Value, Error> {
WaitingCount,
};
- // By default, assume "binary"
- // Then override to integer or string if the spec clearly says so.
match id {
// Integers
UserID