From 142a5ac135c65ee71258552ec859e990fff2d426 Mon Sep 17 00:00:00 2001 From: syui Date: Mon, 9 Jun 2025 03:58:38 +0900 Subject: [PATCH] fix cargo --- .claude/settings.local.json | 3 ++- src/database.rs | 5 ++--- src/handlers/auth.rs | 2 +- src/handlers/mod.rs | 6 +----- src/handlers/sync.rs | 2 +- src/main.rs | 6 ++---- src/models.rs | 8 ++++++++ src/services/atproto.rs | 11 ++++++++++- src/services/card_master.rs | 7 ++++++- src/services/gacha.rs | 5 +---- src/services/mod.rs | 5 +---- src/services/user.rs | 7 +++++++ 12 files changed, 42 insertions(+), 25 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index a217b89..e5925e9 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -26,7 +26,8 @@ "Bash(npm install:*)", "WebFetch(domain:raw.githubusercontent.com)", "WebFetch(domain:www.npmjs.com)", - "Bash(rm:*)" + "Bash(rm:*)", + "Bash(cargo:*)" ], "deny": [] } diff --git a/src/database.rs b/src/database.rs index 572d54b..0eeaefa 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,7 +1,6 @@ -use sqlx::{Pool, Postgres, Sqlite, Row}; +use sqlx::{Pool, Postgres, Sqlite}; use sqlx::migrate::MigrateDatabase; use crate::error::{AppError, AppResult}; -use std::str::FromStr; #[derive(Clone)] pub enum Database { @@ -20,7 +19,7 @@ impl Database { Ok(Database::Postgres(pool)) } else if database_url.starts_with("sqlite://") { // Extract the path from sqlite:// URL - let db_path = database_url.trim_start_matches("sqlite://"); + let _db_path = database_url.trim_start_matches("sqlite://"); // Create the database file if it doesn't exist if !Sqlite::database_exists(database_url).await.unwrap_or(false) { diff --git a/src/handlers/auth.rs b/src/handlers/auth.rs index ae95bac..c8fe0ca 100644 --- a/src/handlers/auth.rs +++ b/src/handlers/auth.rs @@ -40,7 +40,7 @@ async fn login( .create_access_token(&user, state.settings.access_token_expire_minutes)?; // Create or update user in database - let db_user = create_or_update_user(&state, &user.did, &user.handle).await?; + let _db_user = create_or_update_user(&state, &user.did, &user.handle).await?; Ok(Json(LoginResponse { access_token, diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 3672408..36ade7b 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -1,7 +1,3 @@ pub mod auth; pub mod cards; -pub mod sync; - -pub use auth::*; -pub use cards::*; -pub use sync::*; \ No newline at end of file +pub mod sync; \ No newline at end of file diff --git a/src/handlers/sync.rs b/src/handlers/sync.rs index 462ebfd..bc78a01 100644 --- a/src/handlers/sync.rs +++ b/src/handlers/sync.rs @@ -6,7 +6,7 @@ use axum::{ }; use crate::{ - error::{AppError, AppResult}, + error::AppResult, AppState, }; diff --git a/src/main.rs b/src/main.rs index df0300d..bb87df1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,13 @@ use anyhow::Result; use axum::{ - extract::State, - http::StatusCode, response::Json, - routing::{get, post}, + routing::get, Router, }; use serde_json::{json, Value}; use std::net::SocketAddr; use tower_http::cors::CorsLayer; -use tracing::{info, warn}; +use tracing::info; mod config; mod database; diff --git a/src/models.rs b/src/models.rs index 59e4d30..e93c50a 100644 --- a/src/models.rs +++ b/src/models.rs @@ -189,6 +189,7 @@ pub struct UserCardWithMaster { /// Database query result for JOIN operations #[derive(Debug, Clone, FromRow)] +#[allow(dead_code)] pub struct UserCardWithMasterQuery { // user_cards fields pub id: i32, @@ -266,21 +267,25 @@ pub struct GachaProbabilities { /// External Data Models (from ai.json) #[derive(Debug, Deserialize)] +#[allow(dead_code)] pub struct ExternalCardData { pub ai: AiData, } #[derive(Debug, Deserialize)] +#[allow(dead_code)] pub struct AiData { pub card: CardData, } #[derive(Debug, Deserialize)] +#[allow(dead_code)] pub struct CardData { pub cards: Vec, } #[derive(Debug, Deserialize)] +#[allow(dead_code)] pub struct ExternalCard { pub id: i32, pub name: String, @@ -291,17 +296,20 @@ pub struct ExternalCard { } #[derive(Debug, Deserialize)] +#[allow(dead_code)] pub struct CpRange { pub min: i32, pub max: i32, } #[derive(Debug, Deserialize)] +#[allow(dead_code)] pub struct LangData { pub ja: Option, } #[derive(Debug, Deserialize)] +#[allow(dead_code)] pub struct JapaneseData { pub name: Option, pub skill: Option, diff --git a/src/services/atproto.rs b/src/services/atproto.rs index a7c5bde..7818f4d 100644 --- a/src/services/atproto.rs +++ b/src/services/atproto.rs @@ -5,11 +5,13 @@ use crate::{ use reqwest::Client; use serde_json::json; +#[allow(dead_code)] pub struct AtprotoService { client: Client, session: Option, } +#[allow(dead_code)] impl AtprotoService { pub fn new() -> Self { Self { @@ -18,6 +20,7 @@ impl AtprotoService { } } + #[allow(dead_code)] pub fn with_session(session: String) -> Self { Self { client: Client::new(), @@ -26,11 +29,12 @@ impl AtprotoService { } /// Create a card record in user's atproto PDS + #[allow(dead_code)] pub async fn create_card_record( &self, did: &str, card: &UserCard, - master: &CardMaster, + _master: &CardMaster, ) -> AppResult { let session = self.session.as_ref() .ok_or_else(|| AppError::authentication("No atproto session available"))?; @@ -81,6 +85,7 @@ impl AtprotoService { } /// List card records from user's PDS + #[allow(dead_code)] pub async fn list_card_records(&self, did: &str) -> AppResult> { let session = self.session.as_ref() .ok_or_else(|| AppError::authentication("No atproto session available"))?; @@ -119,6 +124,7 @@ impl AtprotoService { } /// Resolve PDS endpoint from DID + #[allow(dead_code)] async fn resolve_pds_from_did(&self, did: &str) -> AppResult { // This is a simplified resolution // In a real implementation, you would: @@ -141,6 +147,7 @@ impl AtprotoService { } /// Resolve PLC DID to PDS endpoint + #[allow(dead_code)] async fn resolve_plc_did(&self, plc_id: &str) -> AppResult { let response = self .client @@ -174,6 +181,7 @@ impl AtprotoService { } /// Authenticate with atproto and get session + #[allow(dead_code)] pub async fn authenticate(&self, identifier: &str, password: &str) -> AppResult<(String, String)> { // Try multiple PDS endpoints for authentication let pds_endpoints = [ @@ -193,6 +201,7 @@ impl AtprotoService { } /// Try authentication at a specific PDS + #[allow(dead_code)] async fn try_authenticate_at_pds( &self, pds_url: &str, diff --git a/src/services/card_master.rs b/src/services/card_master.rs index dc080f2..667422c 100644 --- a/src/services/card_master.rs +++ b/src/services/card_master.rs @@ -3,13 +3,14 @@ use crate::{ models::*, }; use reqwest::Client; -use std::collections::HashMap; +#[allow(dead_code)] pub struct CardMasterService { client: Client, master_url: String, } +#[allow(dead_code)] impl CardMasterService { pub fn new(master_url: String) -> Self { Self { @@ -19,6 +20,7 @@ impl CardMasterService { } /// Fetch card master data from external source (ai.json) + #[allow(dead_code)] pub async fn fetch_external_card_data(&self) -> AppResult> { let response = self .client @@ -44,6 +46,7 @@ impl CardMasterService { } /// Get fallback card data if external fetch fails + #[allow(dead_code)] pub fn get_fallback_card_data(&self) -> Vec { vec![ ExternalCard { @@ -178,6 +181,7 @@ impl CardMasterService { } /// Get card master data, trying external source first then fallback + #[allow(dead_code)] pub async fn get_card_master_data(&self) -> Vec { match self.fetch_external_card_data().await { Ok(cards) => { @@ -192,6 +196,7 @@ impl CardMasterService { } /// Convert external card data to database format + #[allow(dead_code)] pub fn external_to_card_master(external: &ExternalCard) -> CardMaster { let description = if let Some(lang) = &external.lang { if let Some(ja) = &lang.ja { diff --git a/src/services/gacha.rs b/src/services/gacha.rs index 9f24ee3..f59434c 100644 --- a/src/services/gacha.rs +++ b/src/services/gacha.rs @@ -3,12 +3,9 @@ use crate::{ database::{Database, DatabaseTransaction}, error::{AppError, AppResult}, models::*, - query_as, query_one_as, query_optional_as, - services::CardMasterService, }; use chrono::Utc; use rand::Rng; -use std::collections::HashMap; use uuid::Uuid; pub struct GachaService { @@ -128,7 +125,7 @@ impl GachaService { async fn select_card_master( &self, tx: &mut DatabaseTransaction, - rarity: &CardRarity, + _rarity: &CardRarity, _pool_id: Option, ) -> AppResult { // For now, randomly select from all available cards diff --git a/src/services/mod.rs b/src/services/mod.rs index d3692ff..8bf537d 100644 --- a/src/services/mod.rs +++ b/src/services/mod.rs @@ -3,7 +3,4 @@ pub mod card_master; pub mod atproto; pub mod user; -pub use gacha::GachaService; -pub use card_master::CardMasterService; -pub use atproto::AtprotoService; -pub use user::UserService; \ No newline at end of file +pub use gacha::GachaService; \ No newline at end of file diff --git a/src/services/user.rs b/src/services/user.rs index 95d06e0..e69a50e 100644 --- a/src/services/user.rs +++ b/src/services/user.rs @@ -5,8 +5,10 @@ use crate::{ }; use chrono::Utc; +#[allow(dead_code)] pub struct UserService; +#[allow(dead_code)] impl UserService { pub async fn get_user_by_did(db: &Database, did: &str) -> AppResult> { match db { @@ -27,6 +29,7 @@ impl UserService { } } + #[allow(dead_code)] pub async fn create_user(db: &Database, did: &str, handle: &str) -> AppResult { let now = Utc::now(); @@ -58,6 +61,7 @@ impl UserService { } } + #[allow(dead_code)] pub async fn update_user_handle(db: &Database, did: &str, handle: &str) -> AppResult { let now = Utc::now(); @@ -87,6 +91,7 @@ impl UserService { } } + #[allow(dead_code)] pub async fn get_user_card_count(db: &Database, user_did: &str) -> AppResult { match db { Database::Postgres(pool) => { @@ -108,6 +113,7 @@ impl UserService { } } + #[allow(dead_code)] pub async fn get_user_unique_card_count(db: &Database, user_did: &str) -> AppResult { match db { Database::Postgres(pool) => { @@ -133,6 +139,7 @@ impl UserService { } } + #[allow(dead_code)] pub async fn get_user_cards_by_rarity( db: &Database, user_did: &str,