Implement Default for ObsState
This commit is contained in:
parent
fbf7c010cc
commit
cb63492602
|
@ -7,6 +7,9 @@ pub enum ObsState {
|
|||
Connected,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct ParseErr(String);
|
||||
|
||||
impl ObsState {
|
||||
pub fn to_str(&self) -> &'static str {
|
||||
match self {
|
||||
|
@ -29,9 +32,6 @@ impl ObsState {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
||||
pub struct ParseErr(String);
|
||||
|
||||
impl std::str::FromStr for ObsState {
|
||||
type Err = ParseErr;
|
||||
|
||||
|
@ -51,6 +51,12 @@ impl std::fmt::Display for ObsState {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for ObsState {
|
||||
fn default() -> Self {
|
||||
ObsState::Disconnected
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ParseErr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "Invalid OBS state '{}' supplied", self.0)
|
||||
|
|
Loading…
Reference in a new issue