diff --git a/Cargo.toml b/Cargo.toml index dc9d1af..2a58253 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ documentation = "https://docs.rs/activitypub_federation/" default = ["actix-web", "axum"] actix-web = ["dep:actix-web", "dep:http02"] axum = ["dep:axum", "dep:tower"] -diesel = ["dep:diesel"] [lints.rust] warnings = "deny" @@ -75,9 +74,6 @@ tokio = { version = "1.43.0", features = [ "rt-multi-thread", "time", ] } -diesel = { version = "2.2.6", features = [ - "postgres", -], default-features = false, optional = true } futures = "0.3.31" moka = { version = "0.12.10", features = ["future"] } diff --git a/src/fetch/collection_id.rs b/src/fetch/collection_id.rs index 6aa9881..ae17ca0 100644 --- a/src/fetch/collection_id.rs +++ b/src/fetch/collection_id.rs @@ -102,92 +102,3 @@ where self.0.eq(&other.0) && self.1 == other.1 } } - -#[cfg(feature = "diesel")] -const _: () = { - use diesel::{ - backend::Backend, - deserialize::{FromSql, FromStaticSqlRow}, - expression::AsExpression, - internal::derives::as_expression::Bound, - pg::Pg, - query_builder::QueryId, - serialize, - serialize::{Output, ToSql}, - sql_types::{HasSqlType, SingleValue, Text}, - Expression, - Queryable, - }; - - // TODO: this impl only works for Postgres db because of to_string() call which requires reborrow - impl ToSql for CollectionId - where - Kind: Collection, - for<'de2> ::Kind: Deserialize<'de2>, - String: ToSql, - { - fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result { - let v = self.0.to_string(); - >::to_sql(&v, &mut out.reborrow()) - } - } - impl<'expr, Kind, ST> AsExpression for &'expr CollectionId - where - Kind: Collection, - for<'de2> ::Kind: Deserialize<'de2>, - Bound: Expression, - ST: SingleValue, - { - type Expression = Bound; - fn as_expression(self) -> Self::Expression { - Bound::new(self.0.as_str()) - } - } - impl AsExpression for CollectionId - where - Kind: Collection, - for<'de2> ::Kind: Deserialize<'de2>, - Bound: Expression, - ST: SingleValue, - { - type Expression = Bound; - fn as_expression(self) -> Self::Expression { - Bound::new(self.0.to_string()) - } - } - impl FromSql for CollectionId - where - Kind: Collection + Send + 'static, - for<'de2> ::Kind: Deserialize<'de2>, - String: FromSql, - DB: Backend, - DB: HasSqlType, - { - fn from_sql( - raw: DB::RawValue<'_>, - ) -> Result> { - let string: String = FromSql::::from_sql(raw)?; - Ok(CollectionId::parse(&string)?) - } - } - impl Queryable for CollectionId - where - Kind: Collection + Send + 'static, - for<'de2> ::Kind: Deserialize<'de2>, - String: FromStaticSqlRow, - DB: Backend, - DB: HasSqlType, - { - type Row = String; - fn build(row: Self::Row) -> diesel::deserialize::Result { - Ok(CollectionId::parse(&row)?) - } - } - impl QueryId for CollectionId - where - Kind: Collection + 'static, - for<'de2> ::Kind: Deserialize<'de2>, - { - type QueryId = Self; - } -}; diff --git a/src/fetch/object_id.rs b/src/fetch/object_id.rs index 7a3b165..4792cd9 100644 --- a/src/fetch/object_id.rs +++ b/src/fetch/object_id.rs @@ -271,95 +271,6 @@ where } } -#[cfg(feature = "diesel")] -const _: () = { - use diesel::{ - backend::Backend, - deserialize::{FromSql, FromStaticSqlRow}, - expression::AsExpression, - internal::derives::as_expression::Bound, - pg::Pg, - query_builder::QueryId, - serialize, - serialize::{Output, ToSql}, - sql_types::{HasSqlType, SingleValue, Text}, - Expression, - Queryable, - }; - - // TODO: this impl only works for Postgres db because of to_string() call which requires reborrow - impl ToSql for ObjectId - where - Kind: Object, - for<'de2> ::Kind: Deserialize<'de2>, - String: ToSql, - { - fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result { - let v = self.0.to_string(); - >::to_sql(&v, &mut out.reborrow()) - } - } - impl<'expr, Kind, ST> AsExpression for &'expr ObjectId - where - Kind: Object, - for<'de2> ::Kind: Deserialize<'de2>, - Bound: Expression, - ST: SingleValue, - { - type Expression = Bound; - fn as_expression(self) -> Self::Expression { - Bound::new(self.0.as_str()) - } - } - impl AsExpression for ObjectId - where - Kind: Object, - for<'de2> ::Kind: Deserialize<'de2>, - Bound: Expression, - ST: SingleValue, - { - type Expression = Bound; - fn as_expression(self) -> Self::Expression { - Bound::new(self.0.to_string()) - } - } - impl FromSql for ObjectId - where - Kind: Object + Send + 'static, - for<'de2> ::Kind: Deserialize<'de2>, - String: FromSql, - DB: Backend, - DB: HasSqlType, - { - fn from_sql( - raw: DB::RawValue<'_>, - ) -> Result> { - let string: String = FromSql::::from_sql(raw)?; - Ok(ObjectId::parse(&string)?) - } - } - impl Queryable for ObjectId - where - Kind: Object + Send + 'static, - for<'de2> ::Kind: Deserialize<'de2>, - String: FromStaticSqlRow, - DB: Backend, - DB: HasSqlType, - { - type Row = String; - fn build(row: Self::Row) -> diesel::deserialize::Result { - Ok(ObjectId::parse(&row)?) - } - } - impl QueryId for ObjectId - where - Kind: Object + 'static, - for<'de2> ::Kind: Deserialize<'de2>, - { - type QueryId = Self; - } -}; - /// Internal only #[cfg(test)] #[allow(clippy::unwrap_used)]