From f2bf6c9924752e5e1f747cecd17f3929186e7d42 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 9 Feb 2025 23:19:28 +0100 Subject: Correct documentation --- src/field/mod.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src') 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) #[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 { use Value::{Binary, Integer, Text}; @@ -58,8 +52,6 @@ pub fn parse_field_value(id: ID, data: &[u8]) -> Result { WaitingCount, }; - // By default, assume "binary" - // Then override to integer or string if the spec clearly says so. match id { // Integers UserID -- cgit