diff --git a/src/accounts/mod.rs b/src/accounts/mod.rs index f4164ca..63a79dc 100644 --- a/src/accounts/mod.rs +++ b/src/accounts/mod.rs @@ -7,5 +7,7 @@ pub mod manager; pub mod profile; +#[allow(unused_imports)] pub use manager::{add_account, ensure_account_dir, load_or_create, resolve_account, save}; +#[allow(unused_imports)] pub use profile::{account_db_path, validate_account_name, AccountProfile, AccountsConfig}; diff --git a/src/app/chat_filter.rs b/src/app/chat_filter.rs index ec373be..32615fa 100644 --- a/src/app/chat_filter.rs +++ b/src/app/chat_filter.rs @@ -9,6 +9,7 @@ use crate::tdlib::ChatInfo; /// Критерии фильтрации чатов +#[allow(dead_code)] #[derive(Debug, Clone, Default)] pub struct ChatFilterCriteria { /// Фильтр по папке (folder_id) @@ -33,6 +34,7 @@ pub struct ChatFilterCriteria { pub hide_archived: bool, } +#[allow(dead_code)] impl ChatFilterCriteria { /// Создаёт критерии с дефолтными значениями pub fn new() -> Self { @@ -147,8 +149,10 @@ impl ChatFilterCriteria { } /// Централизованный фильтр чатов +#[allow(dead_code)] pub struct ChatFilter; +#[allow(dead_code)] impl ChatFilter { /// Фильтрует список чатов по критериям /// diff --git a/src/app/methods/mod.rs b/src/app/methods/mod.rs index 7b4dcf0..c1f4762 100644 --- a/src/app/methods/mod.rs +++ b/src/app/methods/mod.rs @@ -13,8 +13,13 @@ pub mod modal; pub mod navigation; pub mod search; +#[allow(unused_imports)] pub use compose::ComposeMethods; +#[allow(unused_imports)] pub use messages::MessageMethods; +#[allow(unused_imports)] pub use modal::ModalMethods; +#[allow(unused_imports)] pub use navigation::NavigationMethods; +#[allow(unused_imports)] pub use search::SearchMethods; diff --git a/src/app/methods/search.rs b/src/app/methods/search.rs index f7adbba..11cc8fd 100644 --- a/src/app/methods/search.rs +++ b/src/app/methods/search.rs @@ -51,9 +51,11 @@ pub trait SearchMethods { fn update_search_query(&mut self, new_query: String); /// Get index of selected search result + #[allow(dead_code)] fn get_search_selected_index(&self) -> Option; /// Get all search results + #[allow(dead_code)] fn get_search_results(&self) -> Option<&[MessageInfo]>; } diff --git a/src/app/mod.rs b/src/app/mod.rs index 623236a..64cde32 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -10,6 +10,7 @@ mod state; pub use chat_filter::{ChatFilter, ChatFilterCriteria}; pub use chat_state::{ChatState, InputMode}; +#[allow(unused_imports)] pub use methods::*; pub use state::AppScreen; @@ -107,6 +108,7 @@ pub struct App { /// Время последней отправки typing status (для throttling) pub last_typing_sent: Option, // Image support + #[allow(dead_code)] #[cfg(feature = "images")] pub image_cache: Option, /// Renderer для inline preview в чате (Halfblocks - быстро) @@ -145,6 +147,7 @@ pub struct App { pub last_playback_tick: Option, } +#[allow(dead_code)] impl App { /// Creates a new App instance with the given configuration and client. /// diff --git a/src/audio/cache.rs b/src/audio/cache.rs index 13a5374..ab846aa 100644 --- a/src/audio/cache.rs +++ b/src/audio/cache.rs @@ -103,6 +103,7 @@ impl VoiceCache { } /// Clears all cached files + #[allow(dead_code)] pub fn clear(&mut self) -> Result<(), String> { for (path, _, _) in self.files.values() { let _ = fs::remove_file(path); // Ignore errors diff --git a/src/audio/player.rs b/src/audio/player.rs index a18f7f0..6fceb9b 100644 --- a/src/audio/player.rs +++ b/src/audio/player.rs @@ -139,11 +139,13 @@ impl AudioPlayer { } /// Returns true if a process is active (playing or paused) + #[allow(dead_code)] pub fn is_playing(&self) -> bool { self.current_pid.lock().unwrap().is_some() && !*self.paused.lock().unwrap() } /// Returns true if paused + #[allow(dead_code)] pub fn is_paused(&self) -> bool { self.current_pid.lock().unwrap().is_some() && *self.paused.lock().unwrap() } @@ -153,13 +155,16 @@ impl AudioPlayer { self.current_pid.lock().unwrap().is_none() && !*self.starting.lock().unwrap() } + #[allow(dead_code)] pub fn set_volume(&self, _volume: f32) {} + #[allow(dead_code)] pub fn adjust_volume(&self, _delta: f32) {} pub fn volume(&self) -> f32 { 1.0 } + #[allow(dead_code)] pub fn seek(&self, _delta: Duration) -> Result<(), String> { Err("Seeking not supported".to_string()) } diff --git a/src/config/keybindings.rs b/src/config/keybindings.rs index 1120662..af4eebe 100644 --- a/src/config/keybindings.rs +++ b/src/config/keybindings.rs @@ -89,10 +89,12 @@ impl KeyBinding { Self { key, modifiers: KeyModifiers::CONTROL } } + #[allow(dead_code)] pub fn with_shift(key: KeyCode) -> Self { Self { key, modifiers: KeyModifiers::SHIFT } } + #[allow(dead_code)] pub fn with_alt(key: KeyCode) -> Self { Self { key, modifiers: KeyModifiers::ALT } } diff --git a/src/constants.rs b/src/constants.rs index 692cce6..b8c8559 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -50,6 +50,7 @@ pub const MAX_IMAGE_HEIGHT: u16 = 15; pub const MIN_IMAGE_HEIGHT: u16 = 3; /// Таймаут скачивания файла (в секундах) +#[allow(dead_code)] pub const FILE_DOWNLOAD_TIMEOUT_SECS: u64 = 30; /// Размер кэша изображений по умолчанию (в МБ) diff --git a/src/main.rs b/src/main.rs index 66ef8a6..38eb922 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,10 +37,8 @@ fn parse_account_arg() -> Option { let args: Vec = std::env::args().collect(); let mut i = 1; while i < args.len() { - if args[i] == "--account" { - if i + 1 < args.len() { - return Some(args[i + 1].clone()); - } + if args[i] == "--account" && i + 1 < args.len() { + return Some(args[i + 1].clone()); } i += 1; } @@ -161,7 +159,7 @@ async fn run_app( let polling_handle = tokio::spawn(async move { while !should_stop_clone.load(Ordering::Relaxed) { // receive() с таймаутом 0.1 сек чтобы периодически проверять флаг - let result = tokio::task::spawn_blocking(|| tdlib_rs::receive()).await; + let result = tokio::task::spawn_blocking(tdlib_rs::receive).await; if let Ok(Some((update, _client_id))) = result { if update_tx.send(update).is_err() { break; // Канал закрыт, выходим @@ -248,7 +246,7 @@ async fn run_app( // Проверяем завершение воспроизведения if playback.position >= playback.duration - || app.audio_player.as_ref().map_or(false, |p| p.is_stopped()) + || app.audio_player.as_ref().is_some_and(|p| p.is_stopped()) { stop_playback = true; } diff --git a/src/media/cache.rs b/src/media/cache.rs index d7cd6ce..a67c9e4 100644 --- a/src/media/cache.rs +++ b/src/media/cache.rs @@ -6,11 +6,13 @@ use std::fs; use std::path::PathBuf; /// Кэш изображений с LRU eviction по mtime +#[allow(dead_code)] pub struct ImageCache { cache_dir: PathBuf, max_size_bytes: u64, } +#[allow(dead_code)] impl ImageCache { /// Создаёт новый кэш с указанным лимитом в МБ pub fn new(cache_size_mb: u64) -> Self { @@ -89,6 +91,7 @@ impl ImageCache { } /// Обёртка для установки mtime без внешней зависимости +#[allow(dead_code)] mod filetime { use std::path::Path; diff --git a/src/media/image_renderer.rs b/src/media/image_renderer.rs index 8a35490..2c10e09 100644 --- a/src/media/image_renderer.rs +++ b/src/media/image_renderer.rs @@ -108,6 +108,7 @@ impl ImageRenderer { } /// Удаляет протокол для сообщения + #[allow(dead_code)] pub fn remove(&mut self, msg_id: &MessageId) { let msg_id_i64 = msg_id.as_i64(); self.protocols.remove(&msg_id_i64); @@ -115,6 +116,7 @@ impl ImageRenderer { } /// Очищает все протоколы + #[allow(dead_code)] pub fn clear(&mut self) { self.protocols.clear(); self.access_order.clear(); diff --git a/src/notifications.rs b/src/notifications.rs index 3364c66..5d76078 100644 --- a/src/notifications.rs +++ b/src/notifications.rs @@ -10,6 +10,7 @@ use std::collections::HashSet; use notify_rust::{Notification, Timeout}; /// Manages desktop notifications +#[allow(dead_code)] pub struct NotificationManager { /// Whether notifications are enabled enabled: bool, @@ -25,6 +26,7 @@ pub struct NotificationManager { urgency: String, } +#[allow(dead_code)] impl NotificationManager { /// Creates a new notification manager with default settings pub fn new() -> Self { diff --git a/src/tdlib/auth.rs b/src/tdlib/auth.rs index 3ecabb0..ded0e5b 100644 --- a/src/tdlib/auth.rs +++ b/src/tdlib/auth.rs @@ -5,6 +5,7 @@ use tdlib_rs::functions; /// /// Отслеживает текущий этап аутентификации пользователя, /// от инициализации TDLib до полной авторизации. +#[allow(dead_code)] #[derive(Debug, Clone, PartialEq)] pub enum AuthState { /// Ожидание параметров TDLib (начальное состояние). @@ -72,6 +73,7 @@ pub struct AuthManager { client_id: i32, } +#[allow(dead_code)] impl AuthManager { /// Создает новый менеджер авторизации. /// diff --git a/src/tdlib/chats.rs b/src/tdlib/chats.rs index 1d48d6f..ddc40fc 100644 --- a/src/tdlib/chats.rs +++ b/src/tdlib/chats.rs @@ -371,6 +371,7 @@ impl ChatManager { /// println!("Status: {}", typing_text); /// } /// ``` + #[allow(dead_code)] pub fn get_typing_text(&self) -> Option { self.typing_status .as_ref() diff --git a/src/tdlib/client.rs b/src/tdlib/client.rs index 8fdd053..5ab10b6 100644 --- a/src/tdlib/client.rs +++ b/src/tdlib/client.rs @@ -58,6 +58,7 @@ pub struct TdClient { pub network_state: NetworkState, } +#[allow(dead_code)] impl TdClient { /// Creates a new TDLib client instance. /// diff --git a/src/tdlib/mod.rs b/src/tdlib/mod.rs index 4d54f19..842ebc9 100644 --- a/src/tdlib/mod.rs +++ b/src/tdlib/mod.rs @@ -17,6 +17,7 @@ pub mod users; pub use auth::AuthState; pub use client::TdClient; pub use r#trait::TdClientTrait; +#[allow(unused_imports)] pub use types::{ ChatInfo, FolderInfo, MediaInfo, MessageBuilder, MessageInfo, NetworkState, PhotoDownloadState, PhotoInfo, PlaybackState, PlaybackStatus, ProfileInfo, ReplyInfo, UserOnlineStatus, diff --git a/src/tdlib/trait.rs b/src/tdlib/trait.rs index a46ee2f..bc35045 100644 --- a/src/tdlib/trait.rs +++ b/src/tdlib/trait.rs @@ -14,6 +14,7 @@ use super::ChatInfo; /// /// This trait defines the interface for both real and fake TDLib clients, /// enabling dependency injection and easier testing. +#[allow(dead_code)] #[async_trait] pub trait TdClientTrait: Send { // ============ Auth methods ============ diff --git a/src/tdlib/types.rs b/src/tdlib/types.rs index bab98c4..d1237b3 100644 --- a/src/tdlib/types.rs +++ b/src/tdlib/types.rs @@ -71,6 +71,7 @@ pub struct PhotoInfo { } /// Состояние загрузки фотографии +#[allow(dead_code)] #[derive(Debug, Clone)] pub enum PhotoDownloadState { NotDownloaded, @@ -80,6 +81,7 @@ pub enum PhotoDownloadState { } /// Информация о голосовом сообщении +#[allow(dead_code)] #[derive(Debug, Clone)] pub struct VoiceInfo { pub file_id: i32, @@ -91,6 +93,7 @@ pub struct VoiceInfo { } /// Состояние загрузки голосового сообщения +#[allow(dead_code)] #[derive(Debug, Clone)] pub enum VoiceDownloadState { NotDownloaded, @@ -283,6 +286,7 @@ impl MessageInfo { } /// Возвращает мутабельную ссылку на VoiceInfo (если есть) + #[allow(dead_code)] pub fn voice_info_mut(&mut self) -> Option<&mut VoiceInfo> { match &mut self.content.media { Some(MediaInfo::Voice(info)) => Some(info), @@ -693,6 +697,7 @@ pub struct ImageModalState { } /// Состояние воспроизведения голосового сообщения +#[allow(dead_code)] #[derive(Debug, Clone)] pub struct PlaybackState { /// ID сообщения, которое воспроизводится @@ -708,6 +713,7 @@ pub struct PlaybackState { } /// Статус воспроизведения +#[allow(dead_code)] #[derive(Debug, Clone, PartialEq)] pub enum PlaybackStatus { Playing, diff --git a/src/tdlib/users.rs b/src/tdlib/users.rs index 3090362..264f346 100644 --- a/src/tdlib/users.rs +++ b/src/tdlib/users.rs @@ -213,6 +213,7 @@ impl UserCache { /// # Returns /// /// Имя пользователя (first_name + last_name) или "User {id}" если не найден. + #[allow(dead_code)] pub async fn get_user_name(&self, user_id: UserId) -> String { // Сначала пытаемся получить из кэша if let Some(name) = self.user_names.peek(&user_id) { diff --git a/tests/helpers/app_builder.rs b/tests/helpers/app_builder.rs index 71e2cb3..5301d8c 100644 --- a/tests/helpers/app_builder.rs +++ b/tests/helpers/app_builder.rs @@ -10,6 +10,7 @@ use tele_tui::tdlib::{ChatInfo, MessageInfo}; use tele_tui::types::{ChatId, MessageId}; /// Builder для создания тестового App с FakeTdClient\n///\n/// Использует trait-based DI для подмены TdClient на FakeTdClient в тестах. +#[allow(dead_code)] pub struct TestAppBuilder { config: Config, screen: AppScreen, @@ -34,6 +35,7 @@ impl Default for TestAppBuilder { } } +#[allow(dead_code)] impl TestAppBuilder { pub fn new() -> Self { Self { diff --git a/tests/helpers/fake_tdclient.rs b/tests/helpers/fake_tdclient.rs index 3015a46..c598546 100644 --- a/tests/helpers/fake_tdclient.rs +++ b/tests/helpers/fake_tdclient.rs @@ -9,6 +9,7 @@ use tokio::sync::mpsc; /// Update события от TDLib (упрощённая версия) #[derive(Debug, Clone)] +#[allow(dead_code)] pub enum TdUpdate { NewMessage { chat_id: ChatId, @@ -47,6 +48,7 @@ pub enum TdUpdate { } /// Упрощённый mock TDLib клиента для тестов +#[allow(dead_code)] pub struct FakeTdClient { // Данные pub chats: Arc>>, @@ -86,6 +88,7 @@ pub struct FakeTdClient { } #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct SentMessage { pub chat_id: i64, pub text: String, @@ -94,6 +97,7 @@ pub struct SentMessage { } #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct EditedMessage { pub chat_id: i64, pub message_id: MessageId, @@ -101,6 +105,7 @@ pub struct EditedMessage { } #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct DeletedMessages { pub chat_id: i64, pub message_ids: Vec, @@ -108,6 +113,7 @@ pub struct DeletedMessages { } #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct ForwardedMessages { pub from_chat_id: i64, pub to_chat_id: i64, @@ -115,6 +121,7 @@ pub struct ForwardedMessages { } #[derive(Debug, Clone)] +#[allow(dead_code)] pub struct SearchQuery { pub chat_id: i64, pub query: String, @@ -158,6 +165,7 @@ impl Clone for FakeTdClient { } } +#[allow(dead_code)] impl FakeTdClient { pub fn new() -> Self { Self { diff --git a/tests/helpers/test_data.rs b/tests/helpers/test_data.rs index 82af233..9d655da 100644 --- a/tests/helpers/test_data.rs +++ b/tests/helpers/test_data.rs @@ -5,6 +5,7 @@ use tele_tui::tdlib::{ChatInfo, MessageInfo, ProfileInfo, ReplyInfo}; use tele_tui::types::{ChatId, MessageId}; /// Builder для создания тестового чата +#[allow(dead_code)] pub struct TestChatBuilder { id: i64, title: String, @@ -21,6 +22,7 @@ pub struct TestChatBuilder { draft_text: Option, } +#[allow(dead_code)] impl TestChatBuilder { pub fn new(title: &str, id: i64) -> Self { Self { @@ -100,6 +102,7 @@ impl TestChatBuilder { } /// Builder для создания тестового сообщения +#[allow(dead_code)] pub struct TestMessageBuilder { id: i64, sender_name: String, @@ -118,6 +121,7 @@ pub struct TestMessageBuilder { media_album_id: i64, } +#[allow(dead_code)] impl TestMessageBuilder { pub fn new(content: &str, id: i64) -> Self { Self { diff --git a/tests/navigation.rs b/tests/navigation.rs index 58172e9..d58807d 100644 --- a/tests/navigation.rs +++ b/tests/navigation.rs @@ -74,7 +74,7 @@ async fn test_enter_opens_chat() { #[tokio::test] async fn test_esc_closes_chat() { // Состояние: открыт чат 123 - let selected_chat_id = Some(123); + let _selected_chat_id = Some(123); // Пользователь нажал Esc let selected_chat_id: Option = None; @@ -97,7 +97,7 @@ async fn test_scroll_messages_in_chat() { let client = client.with_messages(123, messages); - let msgs = client.get_messages(123); + let _msgs = client.get_messages(123); // Скролл начинается снизу (последнее сообщение видно) let mut scroll_offset: usize = 0; diff --git a/tests/network_typing.rs b/tests/network_typing.rs index 61365b4..af3cb7c 100644 --- a/tests/network_typing.rs +++ b/tests/network_typing.rs @@ -130,7 +130,7 @@ async fn test_typing_indicator_off() { /// Test: Отправка своего typing status #[tokio::test] async fn test_send_own_typing_status() { - let client = FakeTdClient::new(); + let _client = FakeTdClient::new(); // Пользователь начал печатать в чате 456 // В реальном App вызывается client.send_chat_action(chat_id, ChatAction::Typing)