diff --git a/Cargo.toml b/Cargo.toml index b84aefce..abbca6c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" default-members = ["bot"] members = [ "bot", diff --git a/crates/oxidize-auth/src/lib.rs b/crates/oxidize-auth/src/lib.rs index e6989f12..5d89d3a1 100644 --- a/crates/oxidize-auth/src/lib.rs +++ b/crates/oxidize-auth/src/lib.rs @@ -6,7 +6,7 @@ use std::sync::Arc; use anyhow::{Context, Error, Result}; use chrono::{DateTime, Utc}; use common::{Cooldown, Duration}; -use diesel::backend::{Backend, RawValue}; +use diesel::backend::Backend; use diesel::prelude::*; use diesel::serialize::IsNull; use diesel::serialize::ToSql; @@ -470,7 +470,7 @@ macro_rules! scopes { DB: Backend, String: diesel::deserialize::FromSql, { - fn from_sql(bytes: RawValue<'_, DB>) -> diesel::deserialize::Result { + fn from_sql(bytes: DB::RawValue<'_>) -> diesel::deserialize::Result { let s = String::from_sql(bytes)?; Ok(str::parse(&s)?) } @@ -548,7 +548,7 @@ macro_rules! roles { DB: Backend, String: diesel::deserialize::FromSql, { - fn from_sql(bytes: RawValue<'_, DB>) -> diesel::deserialize::Result { + fn from_sql(bytes: DB::RawValue<'_>) -> diesel::deserialize::Result { let s = String::from_sql(bytes)?; Ok(str::parse(&s)?) } diff --git a/crates/oxidize-common/src/channel.rs b/crates/oxidize-common/src/channel.rs index 2984e223..0b063ac5 100644 --- a/crates/oxidize-common/src/channel.rs +++ b/crates/oxidize-common/src/channel.rs @@ -1,4 +1,4 @@ -use diesel::backend; +use diesel::backend::Backend; use diesel::deserialize::{self, FromSql}; use diesel::serialize::{self, Output, ToSql}; use diesel::sql_types::Text; @@ -135,31 +135,31 @@ impl fmt::Debug for Channel { } } -impl FromSql for OwnedChannel +impl FromSql for OwnedChannel where - D: backend::Backend, - String: FromSql, + DB: Backend, + String: FromSql, { - fn from_sql(value: backend::RawValue<'_, D>) -> deserialize::Result { + fn from_sql(value: DB::RawValue<'_>) -> deserialize::Result { Ok(OwnedChannel { - data: <_ as FromSql>::from_sql(value)?, + data: <_ as FromSql>::from_sql(value)?, }) } } -impl ToSql for Channel +impl ToSql for Channel where - D: backend::Backend, - str: ToSql, + DB: Backend, + str: ToSql, { - fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, D>) -> serialize::Result { - <_ as ToSql>::to_sql(&self.data, out) + fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result { + <_ as ToSql>::to_sql(&self.data, out) } } impl ToSql for OwnedChannel where - D: backend::Backend, + D: Backend, str: ToSql, { fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, D>) -> serialize::Result { diff --git a/crates/oxidize-common/src/models/track_id.rs b/crates/oxidize-common/src/models/track_id.rs index 500ef052..886679c1 100644 --- a/crates/oxidize-common/src/models/track_id.rs +++ b/crates/oxidize-common/src/models/track_id.rs @@ -1,9 +1,9 @@ use std::fmt; -use diesel::backend::{Backend, RawValue}; +use diesel::backend::Backend; +use diesel::query_builder; use diesel::serialize::{IsNull, Output, ToSql}; use diesel::sql_types::Text; -use diesel::{backend, query_builder}; use diesel::{AsExpression, FromSqlRow}; use thiserror::Error; @@ -101,7 +101,7 @@ impl TrackId { // Parse a track id from a URL or URI. if let Ok(url) = str::parse::(s) { match url.host() { - Some(host) if host == url::Host::Domain("open.spotify.com") => { + Some(url::Host::Domain("open.spotify.com")) => { let parts = url.path().split('/').collect::>(); let id = match parts.as_slice() { @@ -168,14 +168,12 @@ impl TrackId { } } -impl ToSql for TrackId +impl ToSql for TrackId where - D: backend::Backend, - String: for<'a> Into< - as query_builder::BindCollector<'a, D>>::Buffer, - >, + DB: Backend, + String: for<'a> Into< as query_builder::BindCollector<'a, DB>>::Buffer>, { - fn to_sql(&self, out: &mut Output<'_, '_, D>) -> diesel::serialize::Result { + fn to_sql(&self, out: &mut Output<'_, '_, DB>) -> diesel::serialize::Result { out.set_value(self.to_string()); Ok(IsNull::No) } @@ -186,7 +184,7 @@ where DB: Backend, String: diesel::deserialize::FromSql, { - fn from_sql(bytes: RawValue<'_, DB>) -> diesel::deserialize::Result { + fn from_sql(bytes: DB::RawValue<'_>) -> diesel::deserialize::Result { let s = String::from_sql(bytes)?; Ok(TrackId::parse_with_prefix_fallback(&s)?) } diff --git a/crates/oxidize-common/src/uri.rs b/crates/oxidize-common/src/uri.rs index 20f9849d..3780b4fb 100644 --- a/crates/oxidize-common/src/uri.rs +++ b/crates/oxidize-common/src/uri.rs @@ -4,7 +4,7 @@ use std::fmt; use std::str::FromStr; -use diesel::backend::{Backend, RawValue}; +use diesel::backend::Backend; use diesel::deserialize::{self, FromSql}; use diesel::serialize::{IsNull, Output, ToSql}; use diesel::sql_types::Text; @@ -91,7 +91,7 @@ where DB: Backend, String: FromSql, { - fn from_sql(bytes: RawValue<'_, DB>) -> deserialize::Result { + fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result { let s = String::from_sql(bytes)?; Ok(Uri::from_str(&s)?) } diff --git a/web/src/session.rs b/web/src/session.rs index 7b50e506..18d73eea 100644 --- a/web/src/session.rs +++ b/web/src/session.rs @@ -47,7 +47,7 @@ impl Session { let data = serde_cbor::to_vec(&value)?; let data = self.sealer.encrypt(&data)?; - let data = BASE64_STANDARD.encode(&data); + let data = BASE64_STANDARD.encode(data); let mut jar = CookieJar::new(); jar.add(self.cookie(name.to_string(), data).finish()); diff --git a/web/src/web.rs b/web/src/web.rs index 55e34d77..79b6e952 100644 --- a/web/src/web.rs +++ b/web/src/web.rs @@ -679,7 +679,7 @@ impl Handler { let exchange_token = flow.exchange_token(); - let r = json_ok(&Login { + let r = json_ok(Login { auth_url: &exchange_token.auth_url, })?; @@ -720,7 +720,7 @@ impl Handler { let key = BASE64_STANDARD.encode(buf); self.db.insert_key(&user.user_id, &key)?; - return json_ok(&KeyInfo { key }); + return json_ok(KeyInfo { key }); #[derive(Serialize)] struct KeyInfo { @@ -739,7 +739,7 @@ impl Handler { async fn get_key(&self, req: &Request) -> Result, Error> { let user = self.verify(req)?; let key = self.db.get_key(&user.user_id)?; - return json_ok(&KeyInfo { key }); + return json_ok(KeyInfo { key }); #[derive(Serialize)] struct KeyInfo { @@ -872,7 +872,7 @@ impl Handler { async fn auth_login(&self, req: &Request) -> Result, Error> { let exchange_token = self.login_flow.exchange_token(); - let r = json_ok(&Login { + let r = json_ok(Login { auth_url: &exchange_token.auth_url, })?;