about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/database/redis/mod.rs23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/database/redis/mod.rs b/src/database/redis/mod.rs
index 3a0d5fc..5b3506a 100644
--- a/src/database/redis/mod.rs
+++ b/src/database/redis/mod.rs
@@ -128,20 +128,20 @@ impl Storage for RedisStorage {
 
     async fn post_exists(&self, url: &str) -> Result<bool> {
         let mut conn = self.redis.get().await.map_err(|e| StorageError::with_source(ErrorKind::Backend, "Error getting a connection from the pool", Box::new(e)))?;
-        Ok(conn.hexists::<&str, &str, bool>(&"posts", url).await?)
+        Ok(conn.hexists::<&str, &str, bool>("posts", url).await?)
     }
 
     async fn get_post(&self, url: &str) -> Result<Option<serde_json::Value>> {
         let mut conn = self.redis.get().await.map_err(|e| StorageError::with_source(ErrorKind::Backend, "Error getting a connection from the pool", Box::new(e)))?;
         match conn
-            .hget::<&str, &str, Option<String>>(&"posts", url)
+            .hget::<&str, &str, Option<String>>("posts", url)
             .await?
         {
             Some(val) => {
                 let parsed = serde_json::from_str::<serde_json::Value>(&val)?;
                 if let Some(new_url) = parsed["see_other"].as_str() {
                     match conn
-                        .hget::<&str, &str, Option<String>>(&"posts", new_url)
+                        .hget::<&str, &str, Option<String>>("posts", new_url)
                         .await?
                     {
                         Some(val) => Ok(Some(serde_json::from_str::<serde_json::Value>(&val)?)),
@@ -194,7 +194,7 @@ impl Storage for RedisStorage {
                 ))
             }
         }
-        conn.hset::<&str, &str, String, ()>(&"posts", key, post.to_string())
+        conn.hset::<&str, &str, String, ()>("posts", key, post.to_string())
             .await?;
         if post["properties"]["url"].is_array() {
             for url in post["properties"]["url"]
@@ -205,7 +205,7 @@ impl Storage for RedisStorage {
             {
                 if url != key && url.starts_with(user) {
                     conn.hset::<&str, &str, String, ()>(
-                        &"posts",
+                        "posts",
                         &url,
                         json!({ "see_other": key }).to_string(),
                     )
@@ -239,7 +239,7 @@ impl Storage for RedisStorage {
         let mut conn = self.redis.get().await?;
         let mut feed;
         match conn
-            .hget::<&str, &str, Option<String>>(&"posts", url)
+            .hget::<&str, &str, Option<String>>("posts", url)
             .await
             .map_err(|e| StorageError::with_source(ErrorKind::Backend, "Error getting a connection from the pool", Box::new(e)))?
         {
@@ -248,7 +248,7 @@ impl Storage for RedisStorage {
         }
         if feed["see_other"].is_string() {
             match conn
-                .hget::<&str, &str, Option<String>>(&"posts", feed["see_other"].as_str().unwrap())
+                .hget::<&str, &str, Option<String>>("posts", feed["see_other"].as_str().unwrap())
                 .await?
             {
                 Some(post) => feed = serde_json::from_str::<serde_json::Value>(&post)?,
@@ -285,10 +285,7 @@ impl Storage for RedisStorage {
                             match conn.hget::<&str, &str, Option<String>>("posts", &url).await {
                                 Ok(post) => match post {
                                     Some(post) => {
-                                        match serde_json::from_str::<serde_json::Value>(&post) {
-                                            Ok(post) => Ok(Some(post)),
-                                            Err(err) => Err(StorageError::from(err))
-                                        }
+                                        Ok(Some(serde_json::from_str(&post)?))
                                     }
                                     // Happens because of a broken link (result of an improper deletion?)
                                     None => Ok(None),
@@ -425,10 +422,10 @@ pub mod tests {
             }
         }
 
-        return RedisInstance {
+        RedisInstance {
             uri,
             child: redis_child,
             _tempdir: tempdir,
-        };
+        }
     }
 }