Skip to content

Commit

Permalink
Cleaned up docs for parse single key value
Browse files Browse the repository at this point in the history
  • Loading branch information
teawithsand committed May 3, 2021
1 parent 6ef992a commit 9ff0d69
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions src/utils/key_value.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
/*
in fact this function is sequence of calls to `parse_single_key_value`
/// parse_key_value parses response in following format:
/// ```text
/// KEYWORD1=VALUE1
/// KEYWORD2=VALUE2
/// ...
/// ```
/// where keywords are A-Z ascii letters and value is either quoted string or just string.
pub fn parse_key_value() {}
*/

/// parse_single_key_value parses response in following format:
/// ```text
/// KEYWORD=VALUE
/// ...
/// ```
///
/// # Params
/// if `must_be_quoted` flag is set an error will be returned when string after equal sign is not quoted string
///
/// # Error
/// It returns an error:
/// - if there is no equal sign
/// - if data before equal sign is not `A-Za-z0-9_ -/$` ascii chars(notice space character)
/// - if value as quoted string enclosing quote is not last character of text
/// - if value is quoted string and enclosing quote is not last character of text
///
/// It *does not* return an error when key value is empty string so format is: `="asdf"`
///
Expand Down Expand Up @@ -54,17 +39,6 @@ pub fn parse_single_key_value(text: &str) -> Result<(&str, &str), ()>
}
let key = &text[..key_offset];
let value = &text[key_offset + 1..];
/*
let (offset, res) = unquote_string(&text[key_offset + 1..]);
if must_be_quoted && offset.is_none() {
return Err(());
}
if let Some(offset) = offset {
if key_offset + 1 + offset != text.len() - 1 {
return Err(()); // end quote is not last char of input text
}
}*/

Ok((key, value))
}
Expand Down

0 comments on commit 9ff0d69

Please sign in to comment.