mirror of
https://tangled.org/tranquil.farm/tranquil-pds
synced 2026-09-01 15:56:55 +00:00
types: sqlx finally behind a feature -> derive Ord & Borrow on newtypes
Lewis: May this revision serve well! <lu5a@proton.me>
This commit is contained in:
@@ -7,6 +7,7 @@ license.workspace = true
|
||||
[dependencies]
|
||||
tranquil-config = { workspace = true }
|
||||
tranquil-crypto = { workspace = true }
|
||||
tranquil-types = { path = "../tranquil-types", default-features = false }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
base32 = { workspace = true }
|
||||
|
||||
@@ -9,6 +9,7 @@ default = []
|
||||
resolve = ["dep:reqwest", "dep:hickory-resolver", "dep:tokio", "dep:parking_lot", "dep:tracing", "dep:urlencoding"]
|
||||
|
||||
[dependencies]
|
||||
tranquil-types = { path = "../tranquil-types", default-features = false }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
|
||||
@@ -5,6 +5,7 @@ edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
tranquil-types = { path = "../tranquil-types", default-features = false }
|
||||
axum = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
hickory-resolver = { version = "0.24", features = ["tokio-runtime"] }
|
||||
|
||||
@@ -4,11 +4,18 @@ version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["sqlx"]
|
||||
sqlx = ["dep:sqlx"]
|
||||
|
||||
[dependencies]
|
||||
base64 = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
cid = { workspace = true }
|
||||
jacquard-common = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
sqlx = { workspace = true }
|
||||
sqlx = { workspace = true, optional = true }
|
||||
thiserror = { workspace = true }
|
||||
uuid = { workspace = true }
|
||||
|
||||
@@ -22,6 +22,12 @@ macro_rules! impl_string_common {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::borrow::Borrow<str> for $name {
|
||||
fn borrow(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for $name {
|
||||
type Target = str;
|
||||
|
||||
@@ -92,9 +98,9 @@ macro_rules! simple_string_newtype {
|
||||
$vis:vis struct $name:ident;
|
||||
) => {
|
||||
$(#[$meta])*
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, sqlx::Type)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type), sqlx(transparent))]
|
||||
#[serde(transparent)]
|
||||
#[sqlx(transparent)]
|
||||
$vis struct $name(String);
|
||||
|
||||
impl $name {
|
||||
@@ -136,9 +142,9 @@ macro_rules! validated_string_newtype {
|
||||
validator = $validator:expr;
|
||||
) => {
|
||||
$(#[$meta])*
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, sqlx::Type)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type), sqlx(transparent))]
|
||||
#[serde(transparent)]
|
||||
#[sqlx(transparent)]
|
||||
$vis struct $name(String);
|
||||
|
||||
impl<'de> Deserialize<'de> for $name {
|
||||
@@ -204,9 +210,9 @@ impl Did {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, sqlx::Type)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type), sqlx(transparent))]
|
||||
#[serde(transparent)]
|
||||
#[sqlx(transparent)]
|
||||
pub struct Handle(String);
|
||||
|
||||
impl<'de> Deserialize<'de> for Handle {
|
||||
@@ -468,9 +474,9 @@ validated_string_newtype! {
|
||||
validator = |s| jacquard_common::types::string::Language::from_str(s).map(|_| ()).map_err(|_| ());
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, sqlx::Type)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type), sqlx(transparent))]
|
||||
#[serde(transparent)]
|
||||
#[sqlx(transparent)]
|
||||
pub struct CidLink(String);
|
||||
|
||||
impl<'de> Deserialize<'de> for CidLink {
|
||||
@@ -663,9 +669,9 @@ impl Deref for PlainPassword {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::Type)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type), sqlx(transparent))]
|
||||
#[serde(transparent)]
|
||||
#[sqlx(transparent)]
|
||||
pub struct PasswordHash(String);
|
||||
|
||||
impl PasswordHash {
|
||||
@@ -749,8 +755,12 @@ simple_string_newtype! {
|
||||
pub struct InviteCode;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, sqlx::Type)]
|
||||
#[sqlx(type_name = "comms_channel", rename_all = "snake_case")]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[cfg_attr(
|
||||
feature = "sqlx",
|
||||
derive(sqlx::Type),
|
||||
sqlx(type_name = "comms_channel", rename_all = "snake_case")
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Copy)]
|
||||
pub enum CommsChannel {
|
||||
@@ -787,8 +797,12 @@ impl fmt::Display for CommsChannel {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, sqlx::Type)]
|
||||
#[sqlx(type_name = "comms_type", rename_all = "snake_case")]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[cfg_attr(
|
||||
feature = "sqlx",
|
||||
derive(sqlx::Type),
|
||||
sqlx(type_name = "comms_type", rename_all = "snake_case")
|
||||
)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CommsType {
|
||||
Verification,
|
||||
|
||||
Reference in New Issue
Block a user