nautilus_common/
component.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use crate::enums::ComponentState;
17
18pub struct PreInitialized;
19pub struct Ready;
20pub struct Starting;
21pub struct Running;
22pub struct Stopping;
23pub struct Stopped;
24pub struct Resuming;
25pub struct Degrading;
26pub struct Degraded;
27pub struct Faulting;
28pub struct Faulted;
29pub struct Disposed;
30
31pub trait State {
32    fn state() -> ComponentState;
33}
34
35impl State for PreInitialized {
36    fn state() -> ComponentState {
37        ComponentState::PreInitialized
38    }
39}
40
41impl State for Ready {
42    fn state() -> ComponentState {
43        ComponentState::Ready
44    }
45}
46
47impl State for Starting {
48    fn state() -> ComponentState {
49        ComponentState::Starting
50    }
51}
52
53impl State for Running {
54    fn state() -> ComponentState {
55        ComponentState::Running
56    }
57}
58
59impl State for Stopping {
60    fn state() -> ComponentState {
61        ComponentState::Stopping
62    }
63}
64
65impl State for Stopped {
66    fn state() -> ComponentState {
67        ComponentState::Stopped
68    }
69}
70
71impl State for Resuming {
72    fn state() -> ComponentState {
73        ComponentState::Resuming
74    }
75}
76
77impl State for Degrading {
78    fn state() -> ComponentState {
79        ComponentState::Degrading
80    }
81}
82
83impl State for Degraded {
84    fn state() -> ComponentState {
85        ComponentState::Degraded
86    }
87}
88
89impl State for Faulting {
90    fn state() -> ComponentState {
91        ComponentState::Faulting
92    }
93}
94
95impl State for Faulted {
96    fn state() -> ComponentState {
97        ComponentState::Faulted
98    }
99}
100
101impl State for Disposed {
102    fn state() -> ComponentState {
103        ComponentState::Disposed
104    }
105}