Skip to content

Commit

Permalink
Fix Clippy lints and deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Dec 6, 2023
1 parent c2d5dbb commit bfcf473
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 32 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
default-members = ["bot"]
members = [
"bot",
Expand Down
6 changes: 3 additions & 3 deletions crates/oxidize-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -470,7 +470,7 @@ macro_rules! scopes {
DB: Backend,
String: diesel::deserialize::FromSql<diesel::sql_types::Text, DB>,
{
fn from_sql(bytes: RawValue<'_, DB>) -> diesel::deserialize::Result<Self> {
fn from_sql(bytes: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
let s = String::from_sql(bytes)?;
Ok(str::parse(&s)?)
}
Expand Down Expand Up @@ -548,7 +548,7 @@ macro_rules! roles {
DB: Backend,
String: diesel::deserialize::FromSql<diesel::sql_types::Text, DB>,
{
fn from_sql(bytes: RawValue<'_, DB>) -> diesel::deserialize::Result<Self> {
fn from_sql(bytes: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
let s = String::from_sql(bytes)?;
Ok(str::parse(&s)?)
}
Expand Down
24 changes: 12 additions & 12 deletions crates/oxidize-common/src/channel.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -135,31 +135,31 @@ impl fmt::Debug for Channel {
}
}

impl<D> FromSql<Text, D> for OwnedChannel
impl<DB> FromSql<Text, DB> for OwnedChannel
where
D: backend::Backend,
String: FromSql<Text, D>,
DB: Backend,
String: FromSql<Text, DB>,
{
fn from_sql(value: backend::RawValue<'_, D>) -> deserialize::Result<Self> {
fn from_sql(value: DB::RawValue<'_>) -> deserialize::Result<Self> {
Ok(OwnedChannel {
data: <_ as FromSql<Text, D>>::from_sql(value)?,
data: <_ as FromSql<Text, DB>>::from_sql(value)?,
})
}
}

impl<D> ToSql<Text, D> for Channel
impl<DB> ToSql<Text, DB> for Channel
where
D: backend::Backend,
str: ToSql<Text, D>,
DB: Backend,
str: ToSql<Text, DB>,
{
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, D>) -> serialize::Result {
<_ as ToSql<Text, D>>::to_sql(&self.data, out)
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, DB>) -> serialize::Result {
<_ as ToSql<Text, DB>>::to_sql(&self.data, out)
}
}

impl<D> ToSql<Text, D> for OwnedChannel
where
D: backend::Backend,
D: Backend,
str: ToSql<Text, D>,
{
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, D>) -> serialize::Result {
Expand Down
18 changes: 8 additions & 10 deletions crates/oxidize-common/src/models/track_id.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -101,7 +101,7 @@ impl TrackId {
// Parse a track id from a URL or URI.
if let Ok(url) = str::parse::<url::Url>(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::<Vec<_>>();

let id = match parts.as_slice() {
Expand Down Expand Up @@ -168,14 +168,12 @@ impl TrackId {
}
}

impl<D> ToSql<Text, D> for TrackId
impl<DB> ToSql<Text, DB> for TrackId
where
D: backend::Backend,
String: for<'a> Into<
<backend::BindCollector<'a, D> as query_builder::BindCollector<'a, D>>::Buffer,
>,
DB: Backend,
String: for<'a> Into<<DB::BindCollector<'a> 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)
}
Expand All @@ -186,7 +184,7 @@ where
DB: Backend,
String: diesel::deserialize::FromSql<Text, DB>,
{
fn from_sql(bytes: RawValue<'_, DB>) -> diesel::deserialize::Result<Self> {
fn from_sql(bytes: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
let s = String::from_sql(bytes)?;
Ok(TrackId::parse_with_prefix_fallback(&s)?)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oxidize-common/src/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,7 +91,7 @@ where
DB: Backend,
String: FromSql<Text, DB>,
{
fn from_sql(bytes: RawValue<'_, DB>) -> deserialize::Result<Self> {
fn from_sql(bytes: DB::RawValue<'_>) -> deserialize::Result<Self> {
let s = String::from_sql(bytes)?;
Ok(Uri::from_str(&s)?)
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions web/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})?;

Expand Down Expand Up @@ -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 {
Expand All @@ -739,7 +739,7 @@ impl Handler {
async fn get_key(&self, req: &Request<Body>) -> Result<Response<Body>, 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 {
Expand Down Expand Up @@ -872,7 +872,7 @@ impl Handler {
async fn auth_login(&self, req: &Request<Body>) -> Result<Response<Body>, 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,
})?;

Expand Down

0 comments on commit bfcf473

Please sign in to comment.