1use thiserror::Error;
6
7pub(crate) mod private {
8 pub struct Internal;
10}
11
12pub trait ReferenceFrame {
14 fn name(&self) -> String;
16 fn abbreviation(&self) -> String;
18 #[doc(hidden)]
19 fn frame_id(&self, _: private::Internal) -> Option<usize> {
20 None
21 }
22}
23
24pub fn frame_id(frame: &impl ReferenceFrame) -> Option<usize> {
26 frame.frame_id(private::Internal)
27}
28
29pub trait QuasiInertial: ReferenceFrame {}
31
32#[derive(Clone, Debug, Error, Eq, PartialEq)]
34#[error("{0} is not a quasi-inertial frame")]
35pub struct NonQuasiInertialFrameError(pub String);
36
37pub trait TryQuasiInertial: ReferenceFrame {
39 fn try_quasi_inertial(&self) -> Result<(), NonQuasiInertialFrameError>;
41}
42
43impl<T: QuasiInertial> TryQuasiInertial for T {
44 fn try_quasi_inertial(&self) -> Result<(), NonQuasiInertialFrameError> {
45 Ok(())
46 }
47}
48
49pub trait BodyFixed: ReferenceFrame {}
51
52#[derive(Clone, Debug, Error)]
54#[error("{0} is not a body-fixed frame")]
55pub struct NonBodyFixedFrameError(pub String);
56
57pub trait TryBodyFixed: ReferenceFrame {
59 fn try_body_fixed(&self) -> Result<(), NonBodyFixedFrameError>;
61}
62
63impl<T: BodyFixed> TryBodyFixed for T {
64 fn try_body_fixed(&self) -> Result<(), NonBodyFixedFrameError> {
65 Ok(())
66 }
67}