1use crate::error::PsruError;
2type Result<T> = std::result::Result<T, PsruError>;
3
4pub(super) fn parse_f64(value: &str) -> Result<f64> {
5 value.parse()
6 .map_err(|_| PsruError::Unparsable {
7 value: value.to_string(), to_type: "double"
8 })
9}
10
11pub(super) fn parse_u32(value: &str) -> Result<u32> {
12 value.parse()
13 .map_err(|_| PsruError::Unparsable {
14 value: value.to_string(), to_type: "integer"
15 })
16}
17
18pub(super) fn parse_bool(value: &str) -> Result<bool> {
19 match value {
20 "1" | "Y" | "y" => Ok(true),
21 "0" | "N" | "n" => Ok(false),
22 _ => Err(PsruError::Unparsable {
23 value: value.to_string(), to_type: "bool"
24 })
25 }
26}