Fix code quality: trailing whitespace, unused imports, clippy warnings

- Fix trailing whitespace in kex.rs and s3.rs
- Add missing KexProposal import in kex_complete.rs
- Auto-fix clippy warnings across all crates
- All 153 tests pass
This commit is contained in:
Warren
2026-06-19 05:21:38 +08:00
parent 4b37e524cf
commit d94cb2df4c
135 changed files with 7256 additions and 4321 deletions

View File

@@ -28,15 +28,15 @@ impl UserPermission {
admin_access: admin,
}
}
pub fn readonly(username: String) -> Self {
UserPermission::new(username, true, false, false)
}
pub fn full_access(username: String) -> Self {
UserPermission::new(username, true, true, false)
}
pub fn admin(username: String) -> Self {
UserPermission::new(username, true, true, true)
}
@@ -57,28 +57,32 @@ impl AccessControlList {
max_connections: 10,
}
}
pub fn add_user(&mut self, permission: UserPermission) {
if let Some(existing) = self.users.iter_mut().find(|u| u.username == permission.username) {
if let Some(existing) = self
.users
.iter_mut()
.find(|u| u.username == permission.username)
{
*existing = permission;
} else {
self.users.push(permission);
}
}
pub fn remove_user(&mut self, username: &str) {
self.users.retain(|u| u.username != username);
}
pub fn get_user(&self, username: &str) -> Option<&UserPermission> {
self.users.iter().find(|u| u.username == username)
}
pub fn has_access(&self, username: &str, require_write: bool) -> bool {
if self.guest_access && !require_write {
return true;
}
self.get_user(username)
.map(|u| {
if require_write {
@@ -89,4 +93,4 @@ impl AccessControlList {
})
.unwrap_or(false)
}
}
}