openstranded-common-helpers
Shared helper functions for parsing .inf file fields across all
OpenStranded domain type crates.
Part of the OpenStranded project. Published on crates.io.
Functions
| Function | Returns | Description |
|---|---|---|
first_str |
Option<&str> |
Get first value of a field as &str |
first_string |
Option<String> |
Get first value as owned String |
first_u32 |
Option<u32> |
Get first value parsed as u32 |
first_f32 |
Option<f32> |
Get first value parsed as f32 |
parse_color |
Option<[u8; 3]> |
Parse "R,G,B" colour string |
parse_optional_u32 |
Option<Option<u32>> |
Parse field that may be "none" or a number |
Usage
[]
= "0.1"
use HashMap;
use ;
let mut fields = new;
fields.insert;
assert_eq!;
Background
These functions were originally duplicated across all 6 openstranded-common-*
domain crates. They operate on the HashMap<String, Vec<String>> structure
produced by the inf2ron parser, extracting the first value of a named field.
Dependencies
Only serde — this is a pure utility crate with no engine dependencies.
License
GPL-3.0-or-later