Remove diesel feature
This commit is contained in:
parent
51bf4b332e
commit
aa93ccd9a1
3 changed files with 0 additions and 182 deletions
|
|
@ -12,7 +12,6 @@ documentation = "https://docs.rs/activitypub_federation/"
|
||||||
default = ["actix-web", "axum"]
|
default = ["actix-web", "axum"]
|
||||||
actix-web = ["dep:actix-web", "dep:http02"]
|
actix-web = ["dep:actix-web", "dep:http02"]
|
||||||
axum = ["dep:axum", "dep:tower"]
|
axum = ["dep:axum", "dep:tower"]
|
||||||
diesel = ["dep:diesel"]
|
|
||||||
|
|
||||||
[lints.rust]
|
[lints.rust]
|
||||||
warnings = "deny"
|
warnings = "deny"
|
||||||
|
|
@ -75,9 +74,6 @@ tokio = { version = "1.43.0", features = [
|
||||||
"rt-multi-thread",
|
"rt-multi-thread",
|
||||||
"time",
|
"time",
|
||||||
] }
|
] }
|
||||||
diesel = { version = "2.2.6", features = [
|
|
||||||
"postgres",
|
|
||||||
], default-features = false, optional = true }
|
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
moka = { version = "0.12.10", features = ["future"] }
|
moka = { version = "0.12.10", features = ["future"] }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,92 +102,3 @@ where
|
||||||
self.0.eq(&other.0) && self.1 == other.1
|
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<Kind, ST> ToSql<ST, Pg> for CollectionId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Collection,
|
|
||||||
for<'de2> <Kind as Collection>::Kind: Deserialize<'de2>,
|
|
||||||
String: ToSql<ST, Pg>,
|
|
||||||
{
|
|
||||||
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
|
|
||||||
let v = self.0.to_string();
|
|
||||||
<String as ToSql<Text, Pg>>::to_sql(&v, &mut out.reborrow())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<'expr, Kind, ST> AsExpression<ST> for &'expr CollectionId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Collection,
|
|
||||||
for<'de2> <Kind as Collection>::Kind: Deserialize<'de2>,
|
|
||||||
Bound<ST, String>: Expression<SqlType = ST>,
|
|
||||||
ST: SingleValue,
|
|
||||||
{
|
|
||||||
type Expression = Bound<ST, &'expr str>;
|
|
||||||
fn as_expression(self) -> Self::Expression {
|
|
||||||
Bound::new(self.0.as_str())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Kind, ST> AsExpression<ST> for CollectionId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Collection,
|
|
||||||
for<'de2> <Kind as Collection>::Kind: Deserialize<'de2>,
|
|
||||||
Bound<ST, String>: Expression<SqlType = ST>,
|
|
||||||
ST: SingleValue,
|
|
||||||
{
|
|
||||||
type Expression = Bound<ST, String>;
|
|
||||||
fn as_expression(self) -> Self::Expression {
|
|
||||||
Bound::new(self.0.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Kind, ST, DB> FromSql<ST, DB> for CollectionId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Collection + Send + 'static,
|
|
||||||
for<'de2> <Kind as Collection>::Kind: Deserialize<'de2>,
|
|
||||||
String: FromSql<ST, DB>,
|
|
||||||
DB: Backend,
|
|
||||||
DB: HasSqlType<ST>,
|
|
||||||
{
|
|
||||||
fn from_sql(
|
|
||||||
raw: DB::RawValue<'_>,
|
|
||||||
) -> Result<Self, Box<dyn ::std::error::Error + Send + Sync>> {
|
|
||||||
let string: String = FromSql::<ST, DB>::from_sql(raw)?;
|
|
||||||
Ok(CollectionId::parse(&string)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Kind, ST, DB> Queryable<ST, DB> for CollectionId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Collection + Send + 'static,
|
|
||||||
for<'de2> <Kind as Collection>::Kind: Deserialize<'de2>,
|
|
||||||
String: FromStaticSqlRow<ST, DB>,
|
|
||||||
DB: Backend,
|
|
||||||
DB: HasSqlType<ST>,
|
|
||||||
{
|
|
||||||
type Row = String;
|
|
||||||
fn build(row: Self::Row) -> diesel::deserialize::Result<Self> {
|
|
||||||
Ok(CollectionId::parse(&row)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Kind> QueryId for CollectionId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Collection + 'static,
|
|
||||||
for<'de2> <Kind as Collection>::Kind: Deserialize<'de2>,
|
|
||||||
{
|
|
||||||
type QueryId = Self;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -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<Kind, ST> ToSql<ST, Pg> for ObjectId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Object,
|
|
||||||
for<'de2> <Kind as Object>::Kind: Deserialize<'de2>,
|
|
||||||
String: ToSql<ST, Pg>,
|
|
||||||
{
|
|
||||||
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
|
|
||||||
let v = self.0.to_string();
|
|
||||||
<String as ToSql<Text, Pg>>::to_sql(&v, &mut out.reborrow())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<'expr, Kind, ST> AsExpression<ST> for &'expr ObjectId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Object,
|
|
||||||
for<'de2> <Kind as Object>::Kind: Deserialize<'de2>,
|
|
||||||
Bound<ST, String>: Expression<SqlType = ST>,
|
|
||||||
ST: SingleValue,
|
|
||||||
{
|
|
||||||
type Expression = Bound<ST, &'expr str>;
|
|
||||||
fn as_expression(self) -> Self::Expression {
|
|
||||||
Bound::new(self.0.as_str())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Kind, ST> AsExpression<ST> for ObjectId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Object,
|
|
||||||
for<'de2> <Kind as Object>::Kind: Deserialize<'de2>,
|
|
||||||
Bound<ST, String>: Expression<SqlType = ST>,
|
|
||||||
ST: SingleValue,
|
|
||||||
{
|
|
||||||
type Expression = Bound<ST, String>;
|
|
||||||
fn as_expression(self) -> Self::Expression {
|
|
||||||
Bound::new(self.0.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Kind, ST, DB> FromSql<ST, DB> for ObjectId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Object + Send + 'static,
|
|
||||||
for<'de2> <Kind as Object>::Kind: Deserialize<'de2>,
|
|
||||||
String: FromSql<ST, DB>,
|
|
||||||
DB: Backend,
|
|
||||||
DB: HasSqlType<ST>,
|
|
||||||
{
|
|
||||||
fn from_sql(
|
|
||||||
raw: DB::RawValue<'_>,
|
|
||||||
) -> Result<Self, Box<dyn ::std::error::Error + Send + Sync>> {
|
|
||||||
let string: String = FromSql::<ST, DB>::from_sql(raw)?;
|
|
||||||
Ok(ObjectId::parse(&string)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Kind, ST, DB> Queryable<ST, DB> for ObjectId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Object + Send + 'static,
|
|
||||||
for<'de2> <Kind as Object>::Kind: Deserialize<'de2>,
|
|
||||||
String: FromStaticSqlRow<ST, DB>,
|
|
||||||
DB: Backend,
|
|
||||||
DB: HasSqlType<ST>,
|
|
||||||
{
|
|
||||||
type Row = String;
|
|
||||||
fn build(row: Self::Row) -> diesel::deserialize::Result<Self> {
|
|
||||||
Ok(ObjectId::parse(&row)?)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<Kind> QueryId for ObjectId<Kind>
|
|
||||||
where
|
|
||||||
Kind: Object + 'static,
|
|
||||||
for<'de2> <Kind as Object>::Kind: Deserialize<'de2>,
|
|
||||||
{
|
|
||||||
type QueryId = Self;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Internal only
|
/// Internal only
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(clippy::unwrap_used)]
|
#[allow(clippy::unwrap_used)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue