chore: update to edition 2024; update packages; rename some stuff

This commit is contained in:
Jef Roosens 2025-06-06 12:33:26 +02:00
parent 82e52bc8f9
commit 275d249320
No known key found for this signature in database
GPG key ID: 21FD3D77D56BAF49
48 changed files with 359 additions and 208 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "gpodder_sqlite"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true
[[bench]]
name = "devices"

16
gpodder_sqlite/Justfile Normal file
View file

@ -0,0 +1,16 @@
build:
cargo build --frozen
alias b := build
test:
cargo test --frozen
alias t := test
check:
cargo fmt --check
cargo clippy \
--frozen \
-- \
--no-deps \
--deny 'clippy::all'
alias c := check

View file

@ -2,7 +2,7 @@ use std::path::PathBuf;
use gpodder::{AuthStore, User};
use gpodder_sqlite::SqliteRepository;
use rand::{distributions::Alphanumeric, Rng};
use rand::{Rng, distributions::Alphanumeric};
pub fn setup() -> (PathBuf, SqliteRepository, Vec<User>) {
let fname: String = rand::thread_rng()

View file

@ -1,6 +1,6 @@
mod common;
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use gpodder::{DevicePatch, DeviceRepository};
pub fn bench_devices_for_user(c: &mut Criterion) {

View file

@ -2,17 +2,17 @@ mod models;
mod repository;
mod schema;
use diesel::Connection;
use diesel::connection::InstrumentationEvent;
use diesel::r2d2::CustomizeConnection;
use diesel::Connection;
pub use repository::SqliteRepository;
use diesel::{
r2d2::{ConnectionManager, Pool},
SqliteConnection,
r2d2::{ConnectionManager, Pool},
};
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
use std::{error::Error, fmt, path::Path};

View file

@ -1,13 +1,13 @@
use std::{fmt, str::FromStr};
use diesel::{
Selectable,
deserialize::{FromSql, FromSqlRow},
expression::AsExpression,
prelude::{Insertable, Queryable},
serialize::ToSql,
sql_types::Text,
sqlite::{Sqlite, SqliteValue},
Selectable,
};
use crate::schema::*;

View file

@ -4,12 +4,12 @@ use gpodder::AuthErr;
use super::SqliteRepository;
use crate::{
DbError,
models::{
session::Session,
user::{NewUser, User},
},
schema::*,
DbError,
};
impl From<User> for gpodder::User {

View file

@ -6,12 +6,12 @@ use gpodder::AuthErr;
use super::SqliteRepository;
use crate::{
DbError,
models::{
device::{Device, DeviceType, NewDevice},
sync_group::SyncGroup,
},
schema::*,
DbError,
};
impl From<DeviceType> for gpodder::DeviceType {
@ -157,10 +157,9 @@ impl gpodder::DeviceRepository for SqliteRepository {
.execute(conn)?;
// Add the non-synchronized devices into the new sync group
let unsynced_device_ids =
devices.iter().filter_map(
|(id, group_id)| if group_id.is_none() { Some(id) } else { None },
);
let unsynced_device_ids = devices
.iter()
.filter_map(|(id, group_id)| if group_id.is_none() { Some(id) } else { None });
diesel::update(devices::table.filter(devices::id.eq_any(unsynced_device_ids)))
.set(devices::sync_group_id.eq(sync_group_id))

View file

@ -4,12 +4,12 @@ use gpodder::AuthErr;
use super::SqliteRepository;
use crate::{
DbError,
models::{
device::Device,
episode_action::{ActionType, EpisodeAction, NewEpisodeAction},
},
schema::*,
DbError,
};
impl From<gpodder::EpisodeAction> for NewEpisodeAction {

View file

@ -6,9 +6,9 @@ use gpodder::AuthErr;
use super::SqliteRepository;
use crate::{
DbError,
models::device_subscription::{DeviceSubscription, NewDeviceSubscription},
schema::*,
DbError,
};
fn set_subscriptions_for_single_device(

View file

@ -65,17 +65,21 @@ fn test_remove_session() {
.insert_session(&new_session)
.expect("insert session shouldn't fail");
assert!(store
.get_session(123)
.expect("get session shouldn't fail")
.is_some());
assert!(
store
.get_session(123)
.expect("get session shouldn't fail")
.is_some()
);
store.remove_session(123).expect("remove shouldn't fail");
assert!(store
.get_session(123)
.expect("get session shouldn't fail")
.is_none());
assert!(
store
.get_session(123)
.expect("get session shouldn't fail")
.is_none()
);
common::teardown(path);
}

View file

@ -1,7 +1,7 @@
use gpodder::{AuthStore, User};
use gpodder_sqlite::SqliteRepository;
use rand::{distributions::Alphanumeric, Rng};
use rand::{Rng, distributions::Alphanumeric};
use std::path::PathBuf;