Coverage Report

Created: 2026-07-30 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/hifitime-4.3.0/src/timescale/fmt.rs
Line
Count
Source
1
/*
2
* Hifitime
3
* Copyright (C) 2017-onward Christopher Rabotin <christopher.rabotin@gmail.com> et al. (cf. https://github.com/nyx-space/hifitime/graphs/contributors)
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
*
8
* Documentation: https://nyxspace.com/
9
*/
10
11
use core::fmt;
12
use core::str::FromStr;
13
14
use crate::ParsingError;
15
16
use super::TimeScale;
17
18
impl fmt::Display for TimeScale {
19
    /// Prints given TimeScale
20
0
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21
0
        match self {
22
0
            Self::TAI => write!(f, "TAI"),
23
0
            Self::TT => write!(f, "TT"),
24
0
            Self::ET => write!(f, "ET"),
25
0
            Self::TDB => write!(f, "TDB"),
26
0
            Self::UTC => write!(f, "UTC"),
27
0
            Self::GPST => write!(f, "GPST"),
28
0
            Self::GST => write!(f, "GST"),
29
0
            Self::BDT => write!(f, "BDT"),
30
0
            Self::QZSST => write!(f, "QZSST"),
31
0
            Self::TCG => write!(f, "TCG"),
32
0
            Self::TCB => write!(f, "TCB"),
33
0
            Self::TL => write!(f, "TL"),
34
0
            Self::TCL => write!(f, "TCL"),
35
        }
36
0
    }
37
}
38
39
impl fmt::LowerHex for TimeScale {
40
    /// Prints given TimeScale in RINEX format
41
    /// ie., standard GNSS constellation name is preferred when possible
42
0
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
43
0
        match self {
44
0
            Self::GPST => write!(f, "GPS"),
45
0
            Self::GST => write!(f, "GAL"),
46
0
            Self::BDT => write!(f, "BDS"),
47
0
            Self::QZSST => write!(f, "QZSS"),
48
0
            _ => write!(f, "{self}"),
49
        }
50
0
    }
51
}
52
53
impl FromStr for TimeScale {
54
    type Err = ParsingError;
55
56
5.37k
    fn from_str(s: &str) -> Result<Self, Self::Err> {
57
5.37k
        let val = s.trim();
58
5.37k
        if val == "UTC" {
59
968
            Ok(Self::UTC)
60
4.41k
        } else if val == "TT" {
61
54
            Ok(Self::TT)
62
4.35k
        } else if val == "TAI" {
63
540
            Ok(Self::TAI)
64
3.81k
        } else if val == "TDB" {
65
451
            Ok(Self::TDB)
66
3.36k
        } else if val == "ET" {
67
84
            Ok(Self::ET)
68
3.28k
        } else if val == "GPST" || val == "GPS" {
69
265
            Ok(Self::GPST)
70
3.01k
        } else if val == "GST" || val == "GAL" {
71
656
            Ok(Self::GST)
72
2.36k
        } else if val == "BDT" || val == "BDS" {
73
945
            Ok(Self::BDT)
74
1.41k
        } else if val == "QZSST" || val == "QZSS" {
75
5
            Ok(Self::QZSST)
76
1.41k
        } else if val == "TCG" {
77
24
            Ok(Self::TCG)
78
1.38k
        } else if val == "TCB" {
79
33
            Ok(Self::TCB)
80
1.35k
        } else if val == "TL" {
81
7
            Ok(Self::TL)
82
1.34k
        } else if val == "TCL" {
83
104
            Ok(Self::TCL)
84
        } else {
85
1.24k
            Err(ParsingError::TimeSystem)
86
        }
87
5.37k
    }
88
}