refactor: apply rust best practices and fix memory optimizations

- Optimized memory allocation in router.rs by offloading JSON serialization to spawn_blocking and using references.
- Prevented full graph duplication on startup in state.rs index rebuild.
- Eliminated massive String allocations in QueryGraphPathHandler BFS loops.
- Avoided temporary Strings in VisualizeGraphHandler via inline writing.
- Fixed O(N) full-graph deduplication in MergeEntitiesHandler to scale efficiently.
This commit is contained in:
Riz Ashraf committed 2026-09-22 22:01:38 +01:00
1 parent 251757f8fc
commit 37003be620
17 files changed
+399 -198

No files matched your search

+4 -5
View File
@@ -41,8 +41,8 @@ impl IntoResponse for AppError {
#[cfg(test)]
mod tests {
use super::*;
use axum::response::IntoResponse;
use axum::http::StatusCode;
use axum::response::IntoResponse;
#[test]
fn test_app_error_not_found() {
@@ -76,15 +76,14 @@ mod tests {
fn test_app_error_display() {
let err = AppError::NotFound("test".into());
assert_eq!(err.to_string(), "Not Found: test");
let err = AppError::Forbidden("test".into());
assert_eq!(err.to_string(), "Forbidden: test");
let err = AppError::Internal("test".into());
assert_eq!(err.to_string(), "Internal Server Error: test");
let err = AppError::BadRequest("test".into());
assert_eq!(err.to_string(), "Bad Request: test");
}
}