chore: clean relative to references and borrows

- lint message: the borrowed expression implements the required traits
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_borrows_for_generic_args
- lint message: this expression creates a reference which is immediately dereferenced by the compiler
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_borrow
- lint message: you don't need to add `&` to all patterns
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#match_ref_pat
- remove useless taken reference
lint message: needlessly taken reference of left operand
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#op_ref
- use &Path instead of &PathBuf as fn parameters
lint message: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#ptr_arg
This commit is contained in:
Gwen Lg
2025-12-13 17:43:05 +01:00
parent 209263eb93
commit 141b3f24f1
35 changed files with 129 additions and 134 deletions
+3 -3
View File
@@ -143,7 +143,7 @@ impl RequestHandler for UpdateAdminTokenRequest {
garage: &Arc<Garage>,
_admin: &Admin,
) -> Result<UpdateAdminTokenResponse, Error> {
let mut token = get_existing_admin_token(&garage, &self.id).await?;
let mut token = get_existing_admin_token(garage, &self.id).await?;
apply_token_updates(&mut token, self.body)?;
@@ -164,7 +164,7 @@ impl RequestHandler for DeleteAdminTokenRequest {
garage: &Arc<Garage>,
_admin: &Admin,
) -> Result<DeleteAdminTokenResponse, Error> {
let token = get_existing_admin_token(&garage, &self.id).await?;
let token = get_existing_admin_token(garage, &self.id).await?;
garage
.admin_token_table
@@ -224,7 +224,7 @@ impl RequestHandler for GetCurrentAdminTokenInfoRequest {
}
let (prefix, _) = self.admin_token.split_once('.').unwrap();
let token = get_existing_admin_token(&garage, &prefix.to_string()).await?;
let token = get_existing_admin_token(garage, &prefix.to_string()).await?;
Ok(GetCurrentAdminTokenInfoResponse(admin_token_info_results(
&token, now,
+7 -7
View File
@@ -64,7 +64,7 @@ impl EndpointHandler<AdminRpc> for AdminApiServer {
match message {
AdminRpc::Proxy(req) => {
info!("Proxied admin API request: {}", req.name());
let res = req.clone().handle(&self.garage, &self).await;
let res = req.clone().handle(&self.garage, self).await;
match res {
Ok(res) => Ok(AdminRpcResponse::ProxyApiOkResponse(res.tagged())),
Err(e) => Ok(AdminRpcResponse::ApiErrorResponse {
@@ -76,7 +76,7 @@ impl EndpointHandler<AdminRpc> for AdminApiServer {
}
AdminRpc::Internal(req) => {
info!("Internal admin API request: {}", req.name());
let res = req.clone().handle(&self.garage, &self).await;
let res = req.clone().handle(&self.garage, self).await;
match res {
Ok(res) => Ok(AdminRpcResponse::InternalApiOkResponse(res)),
Err(e) => Ok(AdminRpcResponse::ApiErrorResponse {
@@ -173,12 +173,12 @@ impl AdminApiServer {
}
match request {
AdminApiRequest::Options(req) => req.handle(&self.garage, &self).await,
AdminApiRequest::CheckDomain(req) => req.handle(&self.garage, &self).await,
AdminApiRequest::Health(req) => req.handle(&self.garage, &self).await,
AdminApiRequest::Metrics(req) => req.handle(&self.garage, &self).await,
AdminApiRequest::Options(req) => req.handle(&self.garage, self).await,
AdminApiRequest::CheckDomain(req) => req.handle(&self.garage, self).await,
AdminApiRequest::Health(req) => req.handle(&self.garage, self).await,
AdminApiRequest::Metrics(req) => req.handle(&self.garage, self).await,
req => {
let res = req.handle(&self.garage, &self).await?;
let res = req.handle(&self.garage, self).await?;
let mut res = json_ok_response(&res)?;
res.headers_mut()
.insert(ACCESS_CONTROL_ALLOW_ORIGIN, HeaderValue::from_static("*"));
+9 -9
View File
@@ -29,7 +29,7 @@ impl RequestHandler for LocalListBlockErrorsRequest {
let errors = errors
.into_iter()
.map(|e| BlockError {
block_hash: hex::encode(&e.hash),
block_hash: hex::encode(e.hash),
refcount: e.refcount,
error_count: e.error_count,
last_try_secs_ago: now.saturating_sub(e.last_try) / 1000,
@@ -61,15 +61,15 @@ impl RequestHandler for LocalGetBlockInfoRequest {
VersionBacklink::MultipartUpload { upload_id } => {
if let Some(u) = garage.mpu_table.get(upload_id, &EmptyKey).await? {
BlockVersionBacklink::Upload {
upload_id: hex::encode(&upload_id),
upload_id: hex::encode(upload_id),
upload_deleted: u.deleted.get(),
upload_garbage_collected: false,
bucket_id: Some(hex::encode(&u.bucket_id)),
bucket_id: Some(hex::encode(u.bucket_id)),
key: Some(u.key.to_string()),
}
} else {
BlockVersionBacklink::Upload {
upload_id: hex::encode(&upload_id),
upload_id: hex::encode(upload_id),
upload_deleted: true,
upload_garbage_collected: true,
bucket_id: None,
@@ -78,12 +78,12 @@ impl RequestHandler for LocalGetBlockInfoRequest {
}
}
VersionBacklink::Object { bucket_id, key } => BlockVersionBacklink::Object {
bucket_id: hex::encode(&bucket_id),
bucket_id: hex::encode(bucket_id),
key: key.to_string(),
},
};
versions.push(BlockVersion {
version_id: hex::encode(&br.version),
version_id: hex::encode(br.version),
ref_deleted: br.deleted.get(),
version_deleted: v.deleted.get(),
garbage_collected: false,
@@ -91,7 +91,7 @@ impl RequestHandler for LocalGetBlockInfoRequest {
});
} else {
versions.push(BlockVersion {
version_id: hex::encode(&br.version),
version_id: hex::encode(br.version),
ref_deleted: br.deleted.get(),
version_deleted: true,
garbage_collected: true,
@@ -100,7 +100,7 @@ impl RequestHandler for LocalGetBlockInfoRequest {
}
}
Ok(LocalGetBlockInfoResponse {
block_hash: hex::encode(&hash),
block_hash: hex::encode(hash),
refcount,
versions,
})
@@ -215,7 +215,7 @@ fn find_block_hash_by_prefix(garage: &Arc<Garage>, prefix: &str) -> Result<Hash,
for item in iter {
let (k, _v) = item.map_err(GarageError::from)?;
let hash = Hash::try_from(&k[..32]).unwrap();
if &hash.as_slice()[..prefix_bin.len()] != prefix_bin {
if hash.as_slice()[..prefix_bin.len()] != prefix_bin {
break;
}
if hex::encode(hash.as_slice()).starts_with(prefix) {
+3 -3
View File
@@ -380,13 +380,13 @@ impl RequestHandler for InspectObjectRequest {
.map(|(vk, vb)| InspectObjectBlock {
part_number: vk.part_number,
offset: vk.offset,
hash: hex::encode(&vb.hash),
hash: hex::encode(vb.hash),
size: vb.size,
})
.collect::<Vec<_>>()
})
.unwrap_or_default();
let uuid = hex::encode(&obj_ver.uuid);
let uuid = hex::encode(obj_ver.uuid);
let timestamp = DateTime::from_timestamp_millis(obj_ver.timestamp as i64)
.expect("invalid timestamp in db");
match &obj_ver.state {
@@ -467,7 +467,7 @@ impl RequestHandler for InspectObjectRequest {
}
Ok(InspectObjectResponse {
bucket_id: hex::encode(&object.bucket_id),
bucket_id: hex::encode(object.bucket_id),
key: object.key,
versions,
})
+1 -1
View File
@@ -143,7 +143,7 @@ impl RequestHandler for GetClusterLayoutHistoryRequest {
.iter()
.map(|node| {
(
hex::encode(&node),
hex::encode(node),
NodeUpdateTrackers {
ack: layout.update_trackers.ack_map.get(node, min_stored),
sync: layout.update_trackers.sync_map.get(node, min_stored),