Refactor and clean up code across multiple modules
- Simplified token type assignment in OAuth service. - Removed unused session_lock module and re-exported Session from zesdex_entities. - Cleaned up session entity by removing unnecessary comments and code. - Consolidated session handling in HTTP handlers for better readability. - Improved formatting and readability in OAuth repository tests. - Enhanced session lock repository with clearer match statements. - Streamlined session repository error handling. - Refined RNG tests for better clarity. - Adjusted module visibility and organization in lib.rs. - Updated IPC client and connection code for better error handling and clarity. - Improved frame handling in IPC for better readability. - Organized module imports and added test utilities for IPC. - Enhanced database connection error handling. - Simplified JWT token creation error handling. - Improved password verification error handling. - Cleaned up state management code for better readability. - Refactored middleware for session authentication and rate limiting. - Simplified clipboard utility for better error handling. - Enhanced logging initialization for better error reporting. - Improved pagination utility with clearer method annotations. - Cleaned up sanitization functions for filenames and paths. - Enhanced slug generation functions for better clarity and usability.
This commit is contained in:
@@ -4,13 +4,6 @@
|
||||
//! [`IpcClient`] wraps a [`Connection`] behind a [`Mutex`] so it can be
|
||||
//! shared across threads (e.g. the TUI event loop and the render task).
|
||||
|
||||
#![allow(
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_precision_loss,
|
||||
clippy::cast_possible_wrap
|
||||
)]
|
||||
|
||||
use crate::conn::Connection;
|
||||
use anyhow::{Context, Result};
|
||||
use serde::de::DeserializeOwned;
|
||||
@@ -43,6 +36,11 @@ impl IpcClient {
|
||||
|
||||
/// Serialise `msg` to JSON and send it as a length-prefixed frame.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if the internal mutex is poisoned (a previous operation
|
||||
/// panicked while holding the lock).
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Delegates to the underlying [`Connection::send`].
|
||||
@@ -58,6 +56,11 @@ impl IpcClient {
|
||||
///
|
||||
/// Returns `Ok(None)` on clean EOF (daemon closed the connection).
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if the internal mutex is poisoned (a previous operation
|
||||
/// panicked while holding the lock).
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Delegates to the underlying [`Connection::receive`].
|
||||
@@ -73,17 +76,13 @@ impl IpcClient {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::os::unix::net::UnixListener;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
struct Ping {
|
||||
seq: u32,
|
||||
}
|
||||
use crate::test_utils::Ping;
|
||||
|
||||
#[test]
|
||||
fn connect_and_round_trip() {
|
||||
let dir = std::env::temp_dir().join(format!("zesdex-ipc-test-{}", std::process::id()));
|
||||
let id = crate::test_utils::TEST_ID.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
||||
let dir = std::env::temp_dir().join(format!("zesdex-ipc-test-{}-{}", std::process::id(), id));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let sock_path = dir.join("test.sock");
|
||||
|
||||
Reference in New Issue
Block a user