aboutsummaryrefslogtreecommitdiff
path: root/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'base/src')
-rw-r--r--base/src/assetfed.rs4
-rw-r--r--base/src/cache.rs4
-rw-r--r--base/src/database.rs1
-rw-r--r--base/src/federation.rs5
-rw-r--r--base/src/lib.rs2
-rw-r--r--base/src/permission.rs8
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
}
}