-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
use super::impl_enum_type; | ||
use serde::Deserialize; | ||
use serde::Serialize; | ||
use std::fmt; | ||
|
||
impl_enum_type!( | ||
#[derive(SqlType, Debug)] | ||
#[diesel(postgres_type(name = "instance_auto_restart", schema = "public"))] | ||
pub struct InstanceAutoRestartEnum; | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq, AsExpression, FromSqlRow, Serialize, Deserialize)] | ||
#[diesel(sql_type = InstanceAutoRestartEnum)] | ||
pub enum InstanceAutoRestart; | ||
|
||
// Enum values | ||
Never => b"never" | ||
AllFailures => b"all_failures" | ||
); | ||
|
||
impl InstanceAutoRestart { | ||
pub fn label(&self) -> &'static str { | ||
match self { | ||
InstanceAutoRestart::Never => "never", | ||
InstanceAutoRestart::AllFailures => "all_failures", | ||
} | ||
} | ||
} | ||
|
||
impl fmt::Display for InstanceAutoRestart { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", self.label()) | ||
} | ||
} | ||
|
||
impl diesel::query_builder::QueryId for InstanceAutoRestart { | ||
type QueryId = (); | ||
const HAS_STATIC_QUERY_ID: bool = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters