Skip to main content

surrealdb_expr/expr/convert/
algorithm.rs

1//! `sql` -> `expr` conversions for [`crate::sql::algorithm`].
2//!
3//! Lives in core rather than beside the AST: `surrealdb-sql` sits below
4//! core, so it cannot name `expr` types.
5
6use crate::sql::algorithm::*;
7
8impl From<Algorithm> for crate::expr::Algorithm {
9	fn from(v: Algorithm) -> Self {
10		match v {
11			Algorithm::EdDSA => Self::EdDSA,
12			Algorithm::Es256 => Self::Es256,
13			Algorithm::Es384 => Self::Es384,
14			Algorithm::Es512 => Self::Es512,
15			Algorithm::Hs256 => Self::Hs256,
16			Algorithm::Hs384 => Self::Hs384,
17			Algorithm::Hs512 => Self::Hs512,
18			Algorithm::Ps256 => Self::Ps256,
19			Algorithm::Ps384 => Self::Ps384,
20			Algorithm::Ps512 => Self::Ps512,
21			Algorithm::Rs256 => Self::Rs256,
22			Algorithm::Rs384 => Self::Rs384,
23			Algorithm::Rs512 => Self::Rs512,
24		}
25	}
26}
27
28impl From<crate::expr::Algorithm> for Algorithm {
29	fn from(v: crate::expr::Algorithm) -> Self {
30		match v {
31			crate::expr::Algorithm::EdDSA => Self::EdDSA,
32			crate::expr::Algorithm::Es256 => Self::Es256,
33			crate::expr::Algorithm::Es384 => Self::Es384,
34			crate::expr::Algorithm::Es512 => Self::Es512,
35			crate::expr::Algorithm::Hs256 => Self::Hs256,
36			crate::expr::Algorithm::Hs384 => Self::Hs384,
37			crate::expr::Algorithm::Hs512 => Self::Hs512,
38			crate::expr::Algorithm::Ps256 => Self::Ps256,
39			crate::expr::Algorithm::Ps384 => Self::Ps384,
40			crate::expr::Algorithm::Ps512 => Self::Ps512,
41			crate::expr::Algorithm::Rs256 => Self::Rs256,
42			crate::expr::Algorithm::Rs384 => Self::Rs384,
43			crate::expr::Algorithm::Rs512 => Self::Rs512,
44		}
45	}
46}