treewide: replace std hashers with rustc_hash alternatives; fix clippy
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I766c36cb53d3d7f9e85b91a67c4131a66a6a6964
This commit is contained in:
parent
d73bb4580d
commit
f831e58723
53 changed files with 343 additions and 394 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::HashMap, path::PathBuf};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use pinakes_plugin_api::{
|
||||
|
|
@ -25,6 +25,7 @@ use pinakes_plugin_api::{
|
|||
ThumbnailOptions,
|
||||
wasm::{HttpRequest, HttpResponse, LogLevel, LogMessage},
|
||||
};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
struct TestPlugin {
|
||||
initialized: bool,
|
||||
|
|
@ -41,7 +42,7 @@ impl TestPlugin {
|
|||
health_status: HealthStatus {
|
||||
healthy: true,
|
||||
message: Some("OK".to_string()),
|
||||
metrics: HashMap::new(),
|
||||
metrics: FxHashMap::default(),
|
||||
},
|
||||
metadata: PluginMetadata {
|
||||
id: "test-plugin".to_string(),
|
||||
|
|
@ -82,7 +83,7 @@ async fn test_plugin_context_creation() {
|
|||
let context = PluginContext {
|
||||
data_dir: PathBuf::from("/data/test-plugin"),
|
||||
cache_dir: PathBuf::from("/cache/test-plugin"),
|
||||
config: HashMap::from([
|
||||
config: FxHashMap::from([
|
||||
("enabled".to_string(), serde_json::json!(true)),
|
||||
("max_items".to_string(), serde_json::json!(100)),
|
||||
]),
|
||||
|
|
@ -119,7 +120,7 @@ async fn test_plugin_context_fields() {
|
|||
let context = PluginContext {
|
||||
data_dir: PathBuf::from("/custom/data"),
|
||||
cache_dir: PathBuf::from("/custom/cache"),
|
||||
config: HashMap::new(),
|
||||
config: FxHashMap::default(),
|
||||
capabilities: Capabilities::default(),
|
||||
};
|
||||
|
||||
|
|
@ -137,7 +138,7 @@ async fn test_plugin_lifecycle() {
|
|||
let context = PluginContext {
|
||||
data_dir: PathBuf::from("/data"),
|
||||
cache_dir: PathBuf::from("/cache"),
|
||||
config: HashMap::new(),
|
||||
config: FxHashMap::default(),
|
||||
capabilities: Capabilities::default(),
|
||||
};
|
||||
plugin.initialize(context).await.unwrap();
|
||||
|
|
@ -164,7 +165,7 @@ async fn test_extracted_metadata_structure() {
|
|||
file_size_bytes: Some(1_500_000),
|
||||
codec: Some("h264".to_string()),
|
||||
bitrate_kbps: Some(5000),
|
||||
custom_fields: HashMap::from([
|
||||
custom_fields: FxHashMap::from([
|
||||
("color_space".to_string(), serde_json::json!("sRGB")),
|
||||
("orientation".to_string(), serde_json::json!(90)),
|
||||
]),
|
||||
|
|
@ -182,7 +183,7 @@ async fn test_extracted_metadata_structure() {
|
|||
async fn test_search_query_serialization() {
|
||||
let query = SearchQuery {
|
||||
query_text: "nature landscape".to_string(),
|
||||
filters: HashMap::from([
|
||||
filters: FxHashMap::from([
|
||||
("type".to_string(), serde_json::json!("image")),
|
||||
("year".to_string(), serde_json::json!(2023)),
|
||||
]),
|
||||
|
|
@ -329,7 +330,7 @@ async fn test_event_serialization() {
|
|||
let event = Event {
|
||||
event_type: EventType::MediaImported,
|
||||
timestamp: "2024-01-15T10:00:00Z".to_string(),
|
||||
data: HashMap::from([
|
||||
data: FxHashMap::from([
|
||||
("path".to_string(), serde_json::json!("/media/test.jpg")),
|
||||
("size".to_string(), serde_json::json!(1024)),
|
||||
]),
|
||||
|
|
@ -347,7 +348,7 @@ async fn test_http_request_serialization() {
|
|||
let request = HttpRequest {
|
||||
method: "GET".to_string(),
|
||||
url: "https://api.example.com/data".to_string(),
|
||||
headers: HashMap::from([
|
||||
headers: FxHashMap::from([
|
||||
("Authorization".to_string(), "Bearer token".to_string()),
|
||||
("Content-Type".to_string(), "application/json".to_string()),
|
||||
]),
|
||||
|
|
@ -366,7 +367,7 @@ async fn test_http_request_serialization() {
|
|||
async fn test_http_response_serialization() {
|
||||
let response = HttpResponse {
|
||||
status: 200,
|
||||
headers: HashMap::from([(
|
||||
headers: FxHashMap::from([(
|
||||
"Content-Type".to_string(),
|
||||
"application/json".to_string(),
|
||||
)]),
|
||||
|
|
@ -386,7 +387,7 @@ async fn test_log_message_serialization() {
|
|||
level: LogLevel::Info,
|
||||
target: "plugin::metadata".to_string(),
|
||||
message: "Metadata extraction complete".to_string(),
|
||||
fields: HashMap::from([
|
||||
fields: FxHashMap::from([
|
||||
("file_count".to_string(), "42".to_string()),
|
||||
("duration_ms".to_string(), "150".to_string()),
|
||||
]),
|
||||
|
|
@ -453,7 +454,7 @@ async fn test_search_index_item_serialization() {
|
|||
"photos".to_string(),
|
||||
],
|
||||
media_type: "image/jpeg".to_string(),
|
||||
metadata: HashMap::from([
|
||||
metadata: FxHashMap::from([
|
||||
("camera".to_string(), serde_json::json!("Canon EOS R5")),
|
||||
("location".to_string(), serde_json::json!("Beach")),
|
||||
]),
|
||||
|
|
@ -474,7 +475,7 @@ async fn test_health_status_variants() {
|
|||
let healthy = HealthStatus {
|
||||
healthy: true,
|
||||
message: Some("All systems operational".to_string()),
|
||||
metrics: HashMap::from([
|
||||
metrics: FxHashMap::from([
|
||||
("items_processed".to_string(), 1000.0),
|
||||
("avg_process_time_ms".to_string(), 45.5),
|
||||
]),
|
||||
|
|
@ -484,7 +485,7 @@ async fn test_health_status_variants() {
|
|||
let unhealthy = HealthStatus {
|
||||
healthy: false,
|
||||
message: Some("Database connection failed".to_string()),
|
||||
metrics: HashMap::new(),
|
||||
metrics: FxHashMap::default(),
|
||||
};
|
||||
assert!(!unhealthy.healthy);
|
||||
assert_eq!(
|
||||
|
|
@ -571,7 +572,7 @@ async fn test_extracted_metadata_default() {
|
|||
async fn test_search_query_structure() {
|
||||
let query = SearchQuery {
|
||||
query_text: "test query".to_string(),
|
||||
filters: HashMap::new(),
|
||||
filters: FxHashMap::default(),
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue