diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-10 15:28:36 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-10 15:28:36 +0200 |
commit | 05d11426a8e60fa060733eb8ae7843bc2ae9725c (patch) | |
tree | 57cfad9cedf1eb50de193f1657b42234745c044e /base/src | |
parent | c0365c8c64f403fd9ee75c0db1a9ed6134633e8f (diff) | |
download | jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.bz2 jellything-05d11426a8e60fa060733eb8ae7843bc2ae9725c.tar.zst |
apply many clippy issue
Diffstat (limited to 'base/src')
-rw-r--r-- | base/src/assetfed.rs | 4 | ||||
-rw-r--r-- | base/src/cache.rs | 4 | ||||
-rw-r--r-- | base/src/database.rs | 1 | ||||
-rw-r--r-- | base/src/federation.rs | 5 | ||||
-rw-r--r-- | base/src/lib.rs | 2 | ||||
-rw-r--r-- | base/src/permission.rs | 8 |
6 files changed, 11 insertions, 13 deletions
diff --git a/base/src/assetfed.rs b/base/src/assetfed.rs index 4ca587b..bb39bbd 100644 --- a/base/src/assetfed.rs +++ b/base/src/assetfed.rs @@ -38,7 +38,7 @@ impl AssetInner { pub fn ser(&self) -> Asset { let mut plaintext = Vec::new(); plaintext.extend(u32::to_le_bytes(VERSION)); - plaintext.extend(bincode::encode_to_vec(&self, bincode::config::standard()).unwrap()); + plaintext.extend(bincode::encode_to_vec(self, bincode::config::standard()).unwrap()); while plaintext.len() % 16 == 0 { plaintext.push(0); @@ -53,7 +53,7 @@ impl AssetInner { Asset(base64::engine::general_purpose::URL_SAFE.encode(&ciphertext)) } pub fn deser(s: &str) -> anyhow::Result<Self> { - let ciphertext = base64::engine::general_purpose::URL_SAFE.decode(&s)?; + let ciphertext = base64::engine::general_purpose::URL_SAFE.decode(s)?; let (ciphertext, nonce) = ciphertext.split_at(ciphertext.len() - 12); let plaintext = ASSET_KEY .decrypt(nonce.into(), ciphertext) diff --git a/base/src/cache.rs b/base/src/cache.rs index 68f191e..5ded6f8 100644 --- a/base/src/cache.rs +++ b/base/src/cache.rs @@ -110,7 +110,7 @@ where return Err(e); } } - rename(temp_path, &location.abs()).context("rename cache")?; + rename(temp_path, location.abs()).context("rename cache")?; } drop(_guard); Ok(location) @@ -150,7 +150,7 @@ where .context("encoding cache object")?; Ok(()) })?; - let mut file = std::fs::File::open(&location.abs())?; + let mut file = std::fs::File::open(location.abs())?; let object = bincode::decode_from_std_read::<T, _, _>(&mut file, bincode::config::standard()) .context("decoding cache object")?; let object = Arc::new(object); diff --git a/base/src/database.rs b/base/src/database.rs index d890956..e57ea3e 100644 --- a/base/src/database.rs +++ b/base/src/database.rs @@ -35,6 +35,7 @@ pub const T_INVITE: TableDefinition<&str, Ser<()>> = TableDefinition::new("invit pub const T_NODE: TableDefinition<&str, Ser<Node>> = TableDefinition::new("node"); pub const T_NODE_EXTENDED: TableDefinition<&str, Ser<ExtendedNode>> = TableDefinition::new("node-ext"); +#[allow(clippy::type_complexity)] pub const T_NODE_IMPORT: TableDefinition<&str, Ser<Vec<(Vec<usize>, Node)>>> = TableDefinition::new("node-import"); diff --git a/base/src/federation.rs b/base/src/federation.rs index 75c16e7..662a7ac 100644 --- a/base/src/federation.rs +++ b/base/src/federation.rs @@ -32,10 +32,7 @@ impl Federation { } pub fn get_instance(&self, host: &String) -> anyhow::Result<&Instance> { - Ok(self - .instances - .get(host) - .ok_or(anyhow!("unknown instance"))?) + self.instances.get(host).ok_or(anyhow!("unknown instance")) } pub async fn get_session(&self, host: &String) -> anyhow::Result<Arc<Session>> { diff --git a/base/src/lib.rs b/base/src/lib.rs index 3eb77e2..1ffaa10 100644 --- a/base/src/lib.rs +++ b/base/src/lib.rs @@ -30,7 +30,7 @@ pub fn load_config() -> GlobalConfig { serde_yaml::from_reader( std::fs::File::open(std::env::var("JELLYTHING_CONFIG").unwrap_or_else(|_| { if std::env::args() - .nth(0) + .next() .unwrap_or_default() .ends_with("jellything") { diff --git a/base/src/permission.rs b/base/src/permission.rs index 15b24a9..358202f 100644 --- a/base/src/permission.rs +++ b/base/src/permission.rs @@ -21,9 +21,9 @@ pub trait PermissionSetExt { impl PermissionSetExt for PermissionSet { fn check_explicit(&self, perm: &UserPermission) -> Option<bool> { self.0 - .get(&perm) - .or(CONF.default_permission_set.0.get(&perm)) - .map(|v| *v) + .get(perm) + .or(CONF.default_permission_set.0.get(perm)) + .copied() } fn assert(&self, perm: &UserPermission) -> Result<(), anyhow::Error> { if self.check(perm) { @@ -61,6 +61,6 @@ fn check_node_permission(perms: &PermissionSet, node: &Node) -> bool { return v; } } - return true; + true } } |