style(format): reformat code with consistent line breaks and spacing

This commit is contained in:
zhenyi
2026-06-12 15:11:32 +08:00
parent 6f40921576
commit 0e13f90834
16 changed files with 381 additions and 347 deletions
+4 -12
View File
@@ -30,7 +30,9 @@ use std::sync::{Arc, OnceLock};
use moka::sync::Cache;
use prost::Message;
use crate::config::{CACHE_ENTRY_OVERHEAD as ENTRY_OVERHEAD, CACHE_MAX_TTL, CACHE_MAX_WEIGHT, CACHE_TTI};
use crate::config::{
CACHE_ENTRY_OVERHEAD as ENTRY_OVERHEAD, CACHE_MAX_TTL, CACHE_MAX_WEIGHT, CACHE_TTI,
};
struct CacheState {
store: Cache<Vec<u8>, Vec<u8>>,
@@ -75,7 +77,6 @@ fn cache() -> &'static Cache<Vec<u8>, Vec<u8>> {
&state().store
}
struct RepoKeyIndex {
repo_to_keys: DashMap<String, Vec<Arc<Vec<u8>>>>,
}
@@ -96,7 +97,6 @@ fn track_cache_key(repo_path: &str, key: Arc<Vec<u8>>) {
.push(key);
}
/// Encode a structured cache key.
///
/// Format: `namespace_len(u8) + namespace + repo_path_len(u16 LE) + repo_path + request_proto`
@@ -136,7 +136,6 @@ fn decode_namespace(key: &[u8]) -> &str {
std::str::from_utf8(&key[1..end]).unwrap_or("unknown")
}
/// Cache a single protobuf response.
///
/// On cache hit, decodes and returns the cached response.
@@ -208,7 +207,6 @@ where
Ok(response)
}
/// Cache a `Vec<Item>` protobuf response using length-delimited encoding.
///
/// Each item is stored sequentially with length-delimited framing, allowing
@@ -297,10 +295,7 @@ where
let response = build()?;
let build_elapsed = start.elapsed();
let total_est: usize = response
.iter()
.map(|item| item.encoded_len() + 10)
.sum();
let total_est: usize = response.iter().map(|item| item.encoded_len() + 10).sum();
let mut data = Vec::with_capacity(total_est);
let mut encode_ok = true;
for item in &response {
@@ -330,7 +325,6 @@ where
Ok(response)
}
/// Encode a protobuf request into a byte vector.
#[inline]
fn encode_request<Req: Message>(request: &Req) -> Vec<u8> {
@@ -341,7 +335,6 @@ fn encode_request<Req: Message>(request: &Req) -> Vec<u8> {
buf
}
/// Invalidate all cache entries for a specific repository.
///
/// Uses the structured key format to extract and match repository paths
@@ -370,7 +363,6 @@ pub(crate) fn invalidate_repo(relative_path: &str) {
}
}
use crate::pb::{ObjectSelector, object_selector};
/// Returns true if the selector is an OID-based reference.