-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Filippo Costa <[email protected]>
- Loading branch information
Showing
13 changed files
with
182 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,3 @@ rustc-ice* | |
|
||
### Project specific | ||
ops/compose/data/* | ||
/frontend/dist | ||
frontend/graphql/api_schema.graphql |
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,43 @@ | ||
use diesel::deserialize::{FromSql, FromSqlRow}; | ||
use diesel::expression::AsExpression; | ||
use diesel::pg::{Pg, PgValue}; | ||
use diesel::serialize::ToSql; | ||
use diesel::sql_types; | ||
|
||
#[derive( | ||
Debug, | ||
Copy, | ||
Clone, | ||
PartialEq, | ||
Eq, | ||
PartialOrd, | ||
Ord, | ||
AsExpression, | ||
FromSqlRow, | ||
async_graphql::Enum, | ||
)] | ||
#[diesel(sql_type = sql_types::Integer)] | ||
#[repr(i32)] | ||
pub enum ApiKeyPermissionLevel { | ||
Admin, | ||
} | ||
|
||
impl ToSql<sql_types::Integer, Pg> for ApiKeyPermissionLevel { | ||
fn to_sql<'b>( | ||
&'b self, | ||
out: &mut diesel::serialize::Output<'b, '_, Pg>, | ||
) -> diesel::serialize::Result { | ||
match self { | ||
ApiKeyPermissionLevel::Admin => <i32 as ToSql<sql_types::Integer, Pg>>::to_sql(&1, out), | ||
} | ||
} | ||
} | ||
|
||
impl FromSql<sql_types::Integer, Pg> for ApiKeyPermissionLevel { | ||
fn from_sql(bytes: PgValue<'_>) -> diesel::deserialize::Result<Self> { | ||
match i32::from_sql(bytes)? { | ||
1 => Ok(ApiKeyPermissionLevel::Admin), | ||
_ => Err(anyhow::anyhow!("invalid permission level").into()), | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.