Skip to main content

Crate openstranded_common_helpers

Crate openstranded_common_helpers 

Source
Expand description

§openstranded-common-helpers

Shared helper functions for parsing .inf file fields across all openstranded-common-* domain type crates.

These functions were previously duplicated in every common-* crate. They operate on the HashMap<String, Vec<String>> structure produced by the inf2ron parser.

§Functions

FunctionReturnsDescription
first_strOption<&str>Get first value of a field as &str
first_stringOption<String>Get first value as owned String
first_u32Option<u32>Get first value parsed as u32
first_f32Option<f32>Get first value parsed as f32
parse_colorOption<[u8; 3]>Parse "R,G,B" colour string
parse_optional_u32Option<u32>Parse a field that may be "none" or a number

Functions§

first_f32
Get the first value of a field parsed as f32.
first_str
Get the first value of a field as &str, if present.
first_string
Get the first value of a field as an owned String.
first_u32
Get the first value of a field parsed as u32.
parse_color
Parse a colour string "R,G,B" into [R, G, B].
parse_optional_u32
Parse a field that may be "none" (returns None) or a number.