Coverage Report

Created: 2026-10-28 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/hifitime-4.3.1/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
61.6k
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21
61.6k
        match self {
22
0
            Self::TAI => write!(f, "TAI"),
23
0
            Self::TT => write!(f, "TT"),
24
0
            Self::ET => write!(f, "ET"),
25
57.5k
            Self::TDB => write!(f, "TDB"),
26
4.14k
            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
61.6k
    }
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
8.67k
    fn from_str(s: &str) -> Result<Self, Self::Err> {
57
8.67k
        let val = s.trim();
58
8.67k
        if val == "UTC" {
59
1.13k
            Ok(Self::UTC)
60
7.53k
        } else if val == "TT" {
61
316
            Ok(Self::TT)
62
7.21k
        } else if val == "TAI" {
63
1.04k
            Ok(Self::TAI)
64
6.17k
        } else if val == "TDB" {
65
952
            Ok(Self::TDB)
66
5.22k
        } else if val == "ET" {
67
144
            Ok(Self::ET)
68
5.08k
        } else if val == "GPST" || val == "GPS" {
69
1.04k
            Ok(Self::GPST)
70
4.04k
        } else if val == "GST" || val == "GAL" {
71
1.14k
            Ok(Self::GST)
72
2.89k
        } else if val == "BDT" || val == "BDS" {
73
1.12k
            Ok(Self::BDT)
74
1.77k
        } else if val == "QZSST" || val == "QZSS" {
75
15
            Ok(Self::QZSST)
76
1.75k
        } else if val == "TCG" {
77
48
            Ok(Self::TCG)
78
1.71k
        } else if val == "TCB" {
79
161
            Ok(Self::TCB)
80
1.54k
        } else if val == "TL" {
81
15
            Ok(Self::TL)
82
1.53k
        } else if val == "TCL" {
83
80
            Ok(Self::TCL)
84
        } else {
85
1.45k
            Err(ParsingError::TimeSystem)
86
        }
87
8.67k
    }
88
}