(s: &str)
| 149 | } |
| 150 | |
| 151 | fn parse_fields(s: &str) -> Result<Vec<(&str, FieldValue)>, IlpError> { |
| 152 | let mut fields = Vec::new(); |
| 153 | for field in s.split(',') { |
| 154 | let field = field.trim(); |
| 155 | if field.is_empty() { |
| 156 | continue; |
| 157 | } |
| 158 | let eq = field |
| 159 | .find('=') |
| 160 | .ok_or_else(|| IlpError::InvalidFieldValue(field.to_string()))?; |
| 161 | let key = &field[..eq]; |
| 162 | let val_str = &field[eq + 1..]; |
| 163 | if key.is_empty() { |
| 164 | return Err(IlpError::InvalidFieldValue(field.to_string())); |
| 165 | } |
| 166 | let value = parse_field_value(val_str)?; |
| 167 | fields.push((key, value)); |
| 168 | } |
| 169 | Ok(fields) |
| 170 | } |
| 171 | |
| 172 | fn parse_field_value(s: &str) -> Result<FieldValue, IlpError> { |
| 173 | if s.is_empty() { |
no test coverage detected