openstranded-common-helpers 0.1.0

OpenStranded shared helper functions for .inf field parsing
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented6 out of 6 items with examples
  • Size
  • Source code size: 48.43 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 304.12 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • OpenStranded/common-helpers
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • AvengerAnubis

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

[dependencies]
openstranded-common-helpers = "0.1"
use std::collections::HashMap;
use openstranded_common_helpers::{first_str, first_u32};

let mut fields = HashMap::new();
fields.insert("id".into(), vec!["42".into()]);
assert_eq!(first_u32(&fields, "id"), Some(42));

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