From ae03334a64b1d7d6506ffb60a01f5c7f941900a6 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 6 Nov 2022 21:15:12 -0800 Subject: pds: partial clippy clean --- adenosine-pds/src/repo.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'adenosine-pds/src/repo.rs') diff --git a/adenosine-pds/src/repo.rs b/adenosine-pds/src/repo.rs index 442f81b..c75ba15 100644 --- a/adenosine-pds/src/repo.rs +++ b/adenosine-pds/src/repo.rs @@ -8,7 +8,6 @@ use libipld::multihash::Code; use libipld::prelude::Codec; use libipld::store::DefaultParams; use libipld::{Block, Cid, Ipld}; -use log::debug; use std::borrow::Cow; use std::collections::BTreeMap; use std::collections::HashSet; @@ -74,7 +73,7 @@ impl RepoStore { record: &S, ) -> Result { let block = Block::::encode(DagCborCodec, Code::Sha2_256, record)?; - let cid = block.cid().clone(); + let cid = *block.cid(); self.db .put_block(block, None) .context("writing IPLD DAG-CBOR record to blockstore")?; @@ -84,7 +83,7 @@ impl RepoStore { /// Returns CID that was inserted pub fn put_blob(&mut self, data: &[u8]) -> Result { let block = Block::::encode(libipld::raw::RawCodec, Code::Sha2_256, data)?; - let cid = block.cid().clone(); + let cid = *block.cid(); self.db .put_block(block, None) .context("writing non-record blob to blockstore")?; @@ -164,7 +163,7 @@ impl RepoStore { let mut collections: HashSet = Default::default(); // XXX: confirm that keys actually start with leading slash for k in map.keys() { - let coll = k.split("/").nth(1).unwrap(); + let coll = k.split('/').nth(1).unwrap(); collections.insert(coll.to_string()); } Ok(collections.into_iter().collect()) @@ -216,16 +215,16 @@ impl RepoStore { })?; self.db .alias(did.as_bytes().to_vec(), Some(&Cid::from_str(&commit_cid)?))?; - Ok(commit_cid.to_string()) + Ok(commit_cid) } pub fn mst_from_map(&mut self, map: &BTreeMap) -> Result { // TODO: not unwrap in iter - let mut cid_map: BTreeMap = BTreeMap::from_iter( + let cid_map: BTreeMap = BTreeMap::from_iter( map.iter() - .map(|(k, v)| (k.to_string(), Cid::from_str(&v).unwrap())), + .map(|(k, v)| (k.to_string(), Cid::from_str(v).unwrap())), ); - let mst_cid = generate_mst(&mut self.db, &mut cid_map)?; + let mst_cid = generate_mst(&mut self.db, &cid_map)?; Ok(mst_cid.to_string()) } @@ -237,7 +236,7 @@ impl RepoStore { Ok(cid_map) } - pub fn update_mst(&mut self, mst_cid: &str, mutations: &Vec) -> Result { + pub fn update_mst(&mut self, mst_cid: &str, mutations: &[Mutation]) -> Result { let mut cid_map = self.mst_to_cid_map(mst_cid)?; for m in mutations.iter() { match m { @@ -254,7 +253,7 @@ impl RepoStore { } } } - let mst_cid = generate_mst(&mut self.db, &mut cid_map)?; + let mst_cid = generate_mst(&mut self.db, &cid_map)?; Ok(mst_cid.to_string()) } -- cgit v1.2.3