summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adenosine-cli/src/bin/adenosine.rs4
-rw-r--r--adenosine-pds/src/bin/adenosine-pds.rs10
-rw-r--r--adenosine-pds/src/db_bsky.rs60
-rw-r--r--adenosine-pds/src/lib.rs46
-rw-r--r--adenosine/src/identifiers.rs16
-rw-r--r--adenosine/src/lib.rs2
-rw-r--r--adenosine/src/mst.rs6
-rw-r--r--adenosine/src/plc.rs6
-rw-r--r--adenosine/src/repo.rs37
-rw-r--r--adenosine/src/xrpc.rs4
-rw-r--r--adenosine/tests/test_mst_interop.rs68
11 files changed, 118 insertions, 141 deletions
diff --git a/adenosine-cli/src/bin/adenosine.rs b/adenosine-cli/src/bin/adenosine.rs
index e35d634..86b43eb 100644
--- a/adenosine-cli/src/bin/adenosine.rs
+++ b/adenosine-cli/src/bin/adenosine.rs
@@ -235,7 +235,7 @@ fn main() -> Result<()> {
4..=std::i8::MAX => "trace",
};
// hyper logging is very verbose, so crank that down even if everything else is more verbose
- let log_filter = format!("{},hyper=error", log_level);
+ let log_filter = format!("{log_level},hyper=error");
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or(log_filter))
.format_timestamp(None)
.init();
@@ -266,7 +266,7 @@ fn main() -> Result<()> {
ColorChoice::Never
});
color_stderr.set_color(ColorSpec::new().set_fg(Some(Color::Red)).set_bold(true))?;
- eprintln!("Error: {:?}", err);
+ eprintln!("Error: {err:?}");
color_stderr.set_color(&ColorSpec::new())?;
std::process::exit(1);
}
diff --git a/adenosine-pds/src/bin/adenosine-pds.rs b/adenosine-pds/src/bin/adenosine-pds.rs
index c004098..e92c131 100644
--- a/adenosine-pds/src/bin/adenosine-pds.rs
+++ b/adenosine-pds/src/bin/adenosine-pds.rs
@@ -148,7 +148,7 @@ fn main() -> Result<()> {
};
// hyper logging is very verbose, so crank that down even if everything else is more verbose
- let cli_filter = format!("{},hyper=error", log_level);
+ let cli_filter = format!("{log_level},hyper=error");
// defer to env var config, fallback to CLI settings
let log_filter = std::env::var("RUST_LOG").unwrap_or(cli_filter);
pretty_env_logger::formatted_timed_builder()
@@ -174,12 +174,12 @@ fn main() -> Result<()> {
Some(v) => Some(v),
};
let public_url = match public_url {
- None => format!("http://localhost:{}", port),
- Some(v) if v.is_empty() => format!("http://localhost:{}", port),
+ None => format!("http://localhost:{port}"),
+ Some(v) if v.is_empty() => format!("http://localhost:{port}"),
Some(v) => v,
};
let config = AtpServiceConfig {
- listen_host_port: format!("localhost:{}", port),
+ listen_host_port: format!("localhost:{port}"),
public_url,
registration_domain,
invite_code,
@@ -218,7 +218,7 @@ fn main() -> Result<()> {
recoveryKey: recovery_key,
};
let config = AtpServiceConfig {
- public_url: public_url.unwrap_or(format!("https://{}", handle)),
+ public_url: public_url.unwrap_or(format!("https://{handle}")),
..Default::default()
};
let keypair = KeyPair::from_hex(&pds_secret_key)?;
diff --git a/adenosine-pds/src/db_bsky.rs b/adenosine-pds/src/db_bsky.rs
index ee8e0f3..dfe8299 100644
--- a/adenosine-pds/src/db_bsky.rs
+++ b/adenosine-pds/src/db_bsky.rs
@@ -273,7 +273,7 @@ pub fn bsky_get_thread(
// parse the URI
let did = match uri.repository {
DidOrHost::Did(ref did_type, ref did_body) => {
- Did::from_str(&format!("did:{}:{}", did_type, did_body))?
+ Did::from_str(&format!("did:{did_type}:{did_body}"))?
}
_ => Err(anyhow!("expected a DID, not handle, in uri: {}", uri))?,
};
@@ -412,7 +412,7 @@ fn test_bsky_profile() {
ipld!({"subject": {"did": session.did}, "createdAt": created_at_now()}),
),
Mutation::Create(
- follow_nsid.clone(),
+ follow_nsid,
srv.tid_gen.next_tid(),
ipld!({"subject": {"did": "did:web:external.domain"}, "createdAt": created_at_now()}),
),
@@ -427,7 +427,7 @@ fn test_bsky_profile() {
ipld!({"text": "second post"}),
),
Mutation::Create(
- post_nsid.clone(),
+ post_nsid,
srv.tid_gen.next_tid(),
ipld!({"text": "third post"}),
),
@@ -534,9 +534,9 @@ fn test_bsky_feeds() {
// bob follows alice, likes first post, reposts second, replies third
let alice_post3_uri = format!(
"at://{}/{}/{}",
- alice_did.to_string(),
- post_nsid.to_string(),
- alice_post3_tid.to_string()
+ alice_did,
+ post_nsid,
+ alice_post3_tid
);
let mutations = vec![
Mutation::Create(
@@ -545,19 +545,19 @@ fn test_bsky_feeds() {
ipld!({"subject": {"did": alice_did.to_string()}, "createdAt": created_at_now()}),
),
Mutation::Create(
- like_nsid.clone(),
+ like_nsid,
srv.tid_gen.next_tid(),
- ipld!({"subject": {"uri": format!("at://{}/{}/{}", alice_did.to_string(), post_nsid.to_string(), alice_post1_tid.to_string())}, "createdAt": created_at_now()}),
+ ipld!({"subject": {"uri": format!("at://{}/{}/{}", alice_did, post_nsid, alice_post1_tid)}, "createdAt": created_at_now()}),
),
Mutation::Create(
- repost_nsid.clone(),
+ repost_nsid,
srv.tid_gen.next_tid(),
- ipld!({"subject": {"uri": format!("at://{}/{}/{}", alice_did.to_string(), post_nsid.to_string(), alice_post2_tid.to_string())}, "createdAt": created_at_now()}),
+ ipld!({"subject": {"uri": format!("at://{}/{}/{}", alice_did, post_nsid, alice_post2_tid)}, "createdAt": created_at_now()}),
),
Mutation::Create(
post_nsid.clone(),
srv.tid_gen.next_tid(),
- ipld!({"text": "bob comment on alice post3", "reply": {"parent": {"uri": alice_post3_uri.clone()}, "root": {"uri": alice_post3_uri.clone()}}}),
+ ipld!({"text": "bob comment on alice post3", "reply": {"parent": {"uri": alice_post3_uri.clone()}, "root": {"uri": alice_post3_uri}}}),
),
];
srv.repo
@@ -567,7 +567,7 @@ fn test_bsky_feeds() {
// carol follows bob
let mutations = vec![Mutation::Create(
- follow_nsid.clone(),
+ follow_nsid,
srv.tid_gen.next_tid(),
ipld!({"subject": {"did": bob_did.to_string()}, "createdAt": created_at_now()}),
)];
@@ -584,7 +584,7 @@ fn test_bsky_feeds() {
// test alice timeline: still empty (?)
let alice_timeline = bsky_get_timeline(&mut srv, &alice_did).unwrap();
- println!("{:?}", alice_timeline);
+ println!("{alice_timeline:?}");
assert!(alice_timeline.feed.is_empty());
// test alice feed: should have 3 posts, with correct counts
@@ -595,9 +595,9 @@ fn test_bsky_feeds() {
alice_feed.feed[2].uri,
format!(
"at://{}/{}/{}",
- alice_did.to_string(),
- post_nsid.to_string(),
- alice_post1_tid.to_string()
+ alice_did,
+ post_nsid,
+ alice_post1_tid
)
);
// TODO: CID
@@ -628,16 +628,16 @@ fn test_bsky_feeds() {
let bob_timeline = bsky_get_timeline(&mut srv, &bob_did).unwrap();
println!("BOB TIMELINE ======");
for item in bob_timeline.feed.iter() {
- println!("{:?}", item);
+ println!("{item:?}");
}
assert_eq!(bob_timeline.feed.len(), 3);
assert_eq!(
bob_timeline.feed[2].uri,
format!(
"at://{}/{}/{}",
- alice_did.to_string(),
- post_nsid.to_string(),
- alice_post1_tid.to_string()
+ alice_did,
+ post_nsid,
+ alice_post1_tid
)
);
// TODO: CID
@@ -718,9 +718,9 @@ fn test_bsky_thread() {
bsky_mutate_db(&mut srv.atp_db, &alice_did, mutations).unwrap();
let alice_post1_uri = format!(
"at://{}/{}/{}",
- alice_did.to_string(),
- post_nsid.to_string(),
- alice_post1_tid.to_string()
+ alice_did,
+ post_nsid,
+ alice_post1_tid
);
// bob likes and replies first post
@@ -736,9 +736,9 @@ fn test_bsky_thread() {
bsky_mutate_db(&mut srv.atp_db, &bob_did, mutations).unwrap();
let bob_post1_uri = format!(
"at://{}/{}/{}",
- bob_did.to_string(),
- post_nsid.to_string(),
- bob_post1_tid.to_string()
+ bob_did,
+ post_nsid,
+ bob_post1_tid
);
// alice replies to bob reply
@@ -746,7 +746,7 @@ fn test_bsky_thread() {
let mutations = vec![Mutation::Create(
post_nsid.clone(),
alice_post2_tid.clone(),
- ipld!({"text": "alice second post, replying to bob comment", "reply": {"parent": {"uri": bob_post1_uri.clone()}, "root": {"uri": alice_post1_uri.clone()}}}),
+ ipld!({"text": "alice second post, replying to bob comment", "reply": {"parent": {"uri": bob_post1_uri.clone()}, "root": {"uri": alice_post1_uri}}}),
)];
srv.repo
.mutate_repo(&alice_did, &mutations, &srv.pds_keypair)
@@ -754,9 +754,9 @@ fn test_bsky_thread() {
bsky_mutate_db(&mut srv.atp_db, &alice_did, mutations).unwrap();
let _alice_post2_uri = format!(
"at://{}/{}/{}",
- alice_did.to_string(),
- post_nsid.to_string(),
- alice_post2_tid.to_string()
+ alice_did,
+ post_nsid,
+ alice_post2_tid
);
// get thread from bob's post
diff --git a/adenosine-pds/src/lib.rs b/adenosine-pds/src/lib.rs
index cca9b0d..fb63a11 100644
--- a/adenosine-pds/src/lib.rs
+++ b/adenosine-pds/src/lib.rs
@@ -40,7 +40,7 @@ impl fmt::Display for XrpcError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::BadRequest(msg) | Self::NotFound(msg) | Self::Forbidden(msg) => {
- write!(f, "{}", msg)
+ write!(f, "{msg}")
}
Self::MutexPoisoned => write!(f, "service mutex poisoned"),
}
@@ -255,8 +255,7 @@ impl AtpService {
fn xrpc_required_param(request: &Request, key: &str) -> Result<String> {
Ok(request.get_param(key).ok_or(XrpcError::BadRequest(format!(
- "require '{}' query parameter",
- key
+ "require '{key}' query parameter"
)))?)
}
@@ -308,13 +307,12 @@ fn xrpc_get_handler(
let collection = Nsid::from_str(&xrpc_required_param(request, "collection")?)?;
let rkey = Tid::from_str(&xrpc_required_param(request, "rkey")?)?;
let mut srv = srv.lock().or(Err(XrpcError::MutexPoisoned))?;
- let key = format!("/{}/{}", collection, rkey);
+ let key = format!("/{collection}/{rkey}");
match srv.repo.get_atp_record(&did, &collection, &rkey) {
// TODO: format as JSON, not text debug
Ok(Some(ipld)) => Ok(ipld_into_json_value(ipld)),
Ok(None) => Err(anyhow!(XrpcError::NotFound(format!(
- "could not find record: {}",
- key
+ "could not find record: {key}"
)))),
Err(e) => Err(e),
}
@@ -325,7 +323,7 @@ fn xrpc_get_handler(
srv.repo
.lookup_commit(&did)?
.map(|v| json!({ "root": v.to_string() }))
- .ok_or(XrpcError::NotFound(format!("no repository found for DID: {}", did)).into())
+ .ok_or(XrpcError::NotFound(format!("no repository found for DID: {did}")).into())
}
"com.atproto.repo.listRecords" => {
// TODO: limit, before, after, tid, reverse
@@ -338,13 +336,13 @@ fn xrpc_get_handler(
let commit_cid = &srv.repo.lookup_commit(&did)?.unwrap();
let last_commit = srv.repo.get_commit(commit_cid)?;
let full_map = srv.repo.mst_to_map(&last_commit.mst_cid)?;
- let prefix = format!("/{}/", collection);
+ let prefix = format!("/{collection}/");
for (mst_key, cid) in full_map.iter() {
//debug!("{}", mst_key);
if mst_key.starts_with(&prefix) {
let record = srv.repo.get_ipld(cid)?;
record_list.push(json!({
- "uri": format!("at://{}{}", did, mst_key),
+ "uri": format!("at://{did}{mst_key}"),
"cid": cid.to_string(),
"value": ipld_into_json_value(record),
}));
@@ -367,8 +365,7 @@ fn xrpc_get_handler(
match srv.atp_db.resolve_handle(&handle)? {
Some(did) => Ok(json!({"did": did.to_string()})),
None => Err(XrpcError::NotFound(format!(
- "could not resolve handle internally: {}",
- handle
+ "could not resolve handle internally: {handle}"
)))?,
}
}
@@ -444,8 +441,7 @@ fn xrpc_get_handler(
Ok(json!({"notifications": []}))
}
_ => Err(anyhow!(XrpcError::NotFound(format!(
- "XRPC endpoint handler not found: {}",
- method
+ "XRPC endpoint handler not found: {method}"
)))),
}
}
@@ -531,15 +527,14 @@ fn xrpc_post_handler(
"com.atproto.account.create" => {
// validate account request
let req: com_atproto::AccountRequest = rouille::input::json_input(request)
- .map_err(|e| XrpcError::BadRequest(format!("failed to parse JSON body: {}", e)))?;
+ .map_err(|e| XrpcError::BadRequest(format!("failed to parse JSON body: {e}")))?;
// TODO: validate handle, email, recoverykey
let mut srv = srv.lock().unwrap();
if let Some(ref domain) = srv.config.registration_domain {
// TODO: better matching, should not allow arbitrary sub-domains
if !req.handle.ends_with(domain) {
Err(XrpcError::BadRequest(format!(
- "handle is not under registration domain ({})",
- domain
+ "handle is not under registration domain ({domain})"
)))?;
}
} else {
@@ -557,7 +552,7 @@ fn xrpc_post_handler(
}
"com.atproto.session.create" => {
let req: com_atproto::SessionRequest = rouille::input::json_input(request)
- .map_err(|e| XrpcError::BadRequest(format!("failed to parse JSON body: {}", e)))?;
+ .map_err(|e| XrpcError::BadRequest(format!("failed to parse JSON body: {e}")))?;
let mut srv = srv.lock().unwrap();
let keypair = srv.pds_keypair.clone();
Ok(json!(srv.atp_db.create_session(
@@ -721,8 +716,7 @@ fn xrpc_post_handler(
Ok(json!({}))
}
_ => Err(anyhow!(XrpcError::NotFound(format!(
- "XRPC endpoint handler not found: {}",
- method
+ "XRPC endpoint handler not found: {method}"
)))),
}
}
@@ -773,8 +767,7 @@ fn account_view_handler(
.atp_db
.resolve_handle(handle)?
.ok_or(XrpcError::NotFound(format!(
- "no DID found for handle: {}",
- handle
+ "no DID found for handle: {handle}"
)))?;
Ok(AccountView {
@@ -799,7 +792,7 @@ fn thread_view_handler(
let did = srv.atp_db.resolve_handle(handle)?.unwrap();
// TODO: could construct URI directly
- let uri = AtUri::from_str(&format!("at://{}/{}/{}", did, collection, tid))?;
+ let uri = AtUri::from_str(&format!("at://{did}/{collection}/{tid}"))?;
Ok(ThreadView {
domain: host.to_string(),
did,
@@ -851,13 +844,13 @@ fn collection_view_handler(
let commit_cid = &srv.repo.lookup_commit(&did)?.unwrap();
let last_commit = srv.repo.get_commit(commit_cid)?;
let full_map = srv.repo.mst_to_map(&last_commit.mst_cid)?;
- let prefix = format!("/{}/", collection);
+ let prefix = format!("/{collection}/");
for (mst_key, cid) in full_map.iter() {
debug!("{}", mst_key);
if mst_key.starts_with(&prefix) {
let record = srv.repo.get_ipld(cid)?;
record_list.push(json!({
- "uri": format!("at://{}{}", did, mst_key),
+ "uri": format!("at://{did}{mst_key}"),
"tid": mst_key.split('/').nth(2).unwrap(),
"cid": cid,
"value": ipld_into_json_value(record),
@@ -887,12 +880,11 @@ fn record_view_handler(
let rkey = Tid::from_str(tid)?;
let mut srv = srv.lock().or(Err(XrpcError::MutexPoisoned))?;
- let key = format!("/{}/{}", collection, rkey);
+ let key = format!("/{collection}/{rkey}");
let record = match srv.repo.get_atp_record(&did, &collection, &rkey) {
Ok(Some(ipld)) => ipld_into_json_value(ipld),
Ok(None) => Err(anyhow!(XrpcError::NotFound(format!(
- "could not find record: {}",
- key
+ "could not find record: {key}"
))))?,
Err(e) => Err(e)?,
};
diff --git a/adenosine/src/identifiers.rs b/adenosine/src/identifiers.rs
index 7e93d71..33c2dbe 100644
--- a/adenosine/src/identifiers.rs
+++ b/adenosine/src/identifiers.rs
@@ -40,8 +40,8 @@ impl FromStr for DidOrHost {
impl fmt::Display for DidOrHost {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
- Self::Host(v) => write!(f, "{}", v),
- Self::Did(m, v) => write!(f, "did:{}:{}", m, v),
+ Self::Host(v) => write!(f, "{v}"),
+ Self::Did(m, v) => write!(f, "did:{m}:{v}"),
}
}
}
@@ -101,13 +101,13 @@ impl fmt::Display for AtUri {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "at://{}", self.repository)?;
if let Some(ref c) = self.collection {
- write!(f, "/{}", c)?;
+ write!(f, "/{c}")?;
};
if let Some(ref r) = self.record {
- write!(f, "/{}", r)?;
+ write!(f, "/{r}")?;
};
if let Some(ref v) = self.fragment {
- write!(f, "#{}", v)?;
+ write!(f, "#{v}")?;
};
Ok(())
}
@@ -402,13 +402,13 @@ fn test_ticker() {
let mut prev = ticker.next_tid();
let mut next = ticker.next_tid();
for _ in [0..100] {
- println!("{} >? {}", next, prev);
+ println!("{next} >? {prev}");
assert!(next > prev);
prev = next;
next = ticker.next_tid();
}
- println!("{}", prev);
- assert_eq!(prev, Tid::from_str(&prev.to_string()).unwrap());
+ println!("{prev}");
+ assert_eq!(prev, Tid::from_str(&prev).unwrap());
assert_eq!(next[13..16], prev[13..16]);
let mut other_ticker = Ticker::new();
diff --git a/adenosine/src/lib.rs b/adenosine/src/lib.rs
index 49701a1..06e3174 100644
--- a/adenosine/src/lib.rs
+++ b/adenosine/src/lib.rs
@@ -32,7 +32,7 @@ pub fn created_at_now() -> String {
fn test_created_at_now() {
// eg: 2022-11-22T09:20:44.123Z
let ts = created_at_now();
- println!("{}", ts);
+ println!("{ts}");
assert_eq!(&ts[4..5], "-");
assert_eq!(&ts[7..8], "-");
assert_eq!(&ts[10..11], "T");
diff --git a/adenosine/src/mst.rs b/adenosine/src/mst.rs
index 1d75da1..0d66d5a 100644
--- a/adenosine/src/mst.rs
+++ b/adenosine/src/mst.rs
@@ -110,7 +110,7 @@ pub fn dump_mst_keys(db_path: &PathBuf) -> Result<()> {
// print all the aliases
for (alias, commit_cid) in all_aliases.iter() {
let did = String::from_utf8_lossy(alias);
- println!("{} -> {}", did, commit_cid);
+ println!("{did} -> {commit_cid}");
}
let (did, commit_cid) = all_aliases[0].clone();
@@ -146,7 +146,7 @@ pub fn dump_mst_keys(db_path: &PathBuf) -> Result<()> {
debug!("MST root node: {:?}", mst_node);
debug!("============");
- println!("{}", did);
+ println!("{did}");
print_mst_keys(&mut db, &root.data)?;
Ok(())
}
@@ -389,7 +389,7 @@ fn test_mst_node_cbor() {
}],
};
let block = Block::<DefaultParams>::encode(DagCborCodec, Code::Sha2_256, &node).unwrap();
- println!("{:?}", block);
+ println!("{block:?}");
//assert_eq!(1, 2);
let cid = *block.cid();
assert_eq!(
diff --git a/adenosine/src/plc.rs b/adenosine/src/plc.rs
index c7d7d10..cdedfb9 100644
--- a/adenosine/src/plc.rs
+++ b/adenosine/src/plc.rs
@@ -294,7 +294,7 @@ fn test_debug_did_plc() {
let _did_plc = "did:plc:cg2dfxdh5voabmdjzw2abw3s";
let digest_bytes: Vec<u8> = data_encoding::HEXLOWER
- .decode(&sha256::digest(op_bytes).as_bytes())
+ .decode(sha256::digest(op_bytes).as_bytes())
.expect("SHA-256 digest is always hex string");
let digest_b32 = data_encoding::BASE32_NOPAD
.encode(&digest_bytes)
@@ -350,7 +350,7 @@ fn test_self_verify() {
&keypair,
None,
);
- println!("{:?}", op);
+ println!("{op:?}");
op.verify_self().unwrap();
}
@@ -363,6 +363,6 @@ fn test_known_key() {
&keypair,
None,
);
- println!("{:?}", op);
+ println!("{op:?}");
op.verify_self().unwrap();
}
diff --git a/adenosine/src/repo.rs b/adenosine/src/repo.rs
index 2383e52..280fe6d 100644
--- a/adenosine/src/repo.rs
+++ b/adenosine/src/repo.rs
@@ -196,7 +196,7 @@ impl RepoStore {
} else {
return Ok(None);
};
- let record_key = format!("/{}/{}", collection, tid);
+ let record_key = format!("/{collection}/{tid}");
self.get_mst_record_by_key(&commit.mst_cid, &record_key)
}
@@ -244,14 +244,14 @@ impl RepoStore {
match m {
Mutation::Create(collection, tid, val) => {
let cid = self.put_ipld(val)?;
- cid_map.insert(format!("/{}/{}", collection, tid), cid);
+ cid_map.insert(format!("/{collection}/{tid}"), cid);
}
Mutation::Update(collection, tid, val) => {
let cid = self.put_ipld(val)?;
- cid_map.insert(format!("/{}/{}", collection, tid), cid);
+ cid_map.insert(format!("/{collection}/{tid}"), cid);
}
Mutation::Delete(collection, tid) => {
- cid_map.remove(&format!("/{}/{}", collection, tid));
+ cid_map.remove(&format!("/{collection}/{tid}"));
}
}
}
@@ -378,16 +378,10 @@ fn test_repo_mst() {
.unwrap()
.is_none());
- map.insert("/blobs/1".to_string(), blob_cid.clone());
- map.insert("/blobs/2".to_string(), blob_cid.clone());
- map.insert(
- "/test.records/44444444444444".to_string(),
- record_cid.clone(),
- );
- map.insert(
- "/test.records/22222222222222".to_string(),
- record_cid.clone(),
- );
+ map.insert("/blobs/1".to_string(), blob_cid);
+ map.insert("/blobs/2".to_string(), blob_cid);
+ map.insert("/test.records/44444444444444".to_string(), record_cid);
+ map.insert("/test.records/22222222222222".to_string(), record_cid);
let simple_map_cid = repo.mst_from_map(&map).unwrap();
assert_eq!(map, repo.mst_to_map(&simple_map_cid).unwrap());
@@ -423,15 +417,9 @@ fn test_repo_mst() {
)
.unwrap()
.is_none());
- assert_eq!(
- Some(simple_commit_cid.clone()),
- repo.lookup_commit(&did).unwrap()
- );
+ assert_eq!(Some(simple_commit_cid), repo.lookup_commit(&did).unwrap());
- map.insert(
- "/test.records/33333333333333".to_string(),
- record_cid.clone(),
- );
+ map.insert("/test.records/33333333333333".to_string(), record_cid);
let simple3_map_cid = repo.mst_from_map(&map).unwrap();
let simple3_root_cid = repo
.write_root(meta_cid, Some(simple_commit_cid), simple3_map_cid)
@@ -459,8 +447,5 @@ fn test_repo_mst() {
assert_eq!(commit.did, did);
assert_eq!(commit.prev, Some(simple_commit_cid));
assert_eq!(commit.mst_cid, simple3_map_cid);
- assert_eq!(
- Some(simple3_commit_cid.clone()),
- repo.lookup_commit(&did).unwrap()
- );
+ assert_eq!(Some(simple3_commit_cid), repo.lookup_commit(&did).unwrap());
}
diff --git a/adenosine/src/xrpc.rs b/adenosine/src/xrpc.rs
index 382c7fb..97caa4d 100644
--- a/adenosine/src/xrpc.rs
+++ b/adenosine/src/xrpc.rs
@@ -36,7 +36,7 @@ impl XrpcClient {
pub fn new(host: String, auth_token: Option<String>) -> Result<Self> {
let mut headers = header::HeaderMap::new();
if let Some(token) = &auth_token {
- let mut auth_value = header::HeaderValue::from_str(&format!("Bearer {}", token))?;
+ let mut auth_value = header::HeaderValue::from_str(&format!("Bearer {token}"))?;
auth_value.set_sensitive(true);
headers.insert(header::AUTHORIZATION, auth_value);
};
@@ -61,7 +61,7 @@ impl XrpcClient {
let params: HashMap<String, String> = params.unwrap_or_default();
let res = self
.http_client
- .get(format!("{}/xrpc/{}", self.host, nsid))
+ .get(format!("{}/xrpc/{nsid}", self.host))
.query(&params)
.send()?;
// TODO: refactor this error handling stuff into single method
diff --git a/adenosine/tests/test_mst_interop.rs b/adenosine/tests/test_mst_interop.rs
index ee45019..cfc8727 100644
--- a/adenosine/tests/test_mst_interop.rs
+++ b/adenosine/tests/test_mst_interop.rs
@@ -16,25 +16,25 @@ fn test_known_maps() {
);
let mut trivial_map: BTreeMap<String, Cid> = Default::default();
- trivial_map.insert("asdf".to_string(), cid1.clone());
+ trivial_map.insert("asdf".to_string(), cid1);
assert_eq!(
repo.mst_from_map(&trivial_map).unwrap().to_string(),
"bafyreidaftbr35xhh4lzmv5jcoeufqjh75ohzmz6u56v7n2ippbtxdgqqe"
);
let mut singlelayer2_map: BTreeMap<String, Cid> = Default::default();
- singlelayer2_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1.clone());
+ singlelayer2_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1);
assert_eq!(
repo.mst_from_map(&singlelayer2_map).unwrap().to_string(),
"bafyreid4g5smj6ukhrjasebt6myj7wmtm2eijouteoyueoqgoh6vm5jkae"
);
let mut simple_map: BTreeMap<String, Cid> = Default::default();
- simple_map.insert("asdf".to_string(), cid1.clone());
- simple_map.insert("88bfafc7".to_string(), cid1.clone());
- simple_map.insert("2a92d355".to_string(), cid1.clone());
- simple_map.insert("app.bsky.feed.post/454397e440ec".to_string(), cid1.clone());
- simple_map.insert("app.bsky.feed.post/9adeb165882c".to_string(), cid1.clone());
+ simple_map.insert("asdf".to_string(), cid1);
+ simple_map.insert("88bfafc7".to_string(), cid1);
+ simple_map.insert("2a92d355".to_string(), cid1);
+ simple_map.insert("app.bsky.feed.post/454397e440ec".to_string(), cid1);
+ simple_map.insert("app.bsky.feed.post/9adeb165882c".to_string(), cid1);
assert_eq!(
repo.mst_from_map(&simple_map).unwrap().to_string(),
"bafyreiecb33zh7r2sc3k2wthm6exwzfktof63kmajeildktqc25xj6qzx4"
@@ -50,11 +50,11 @@ fn test_tricky_map() {
Cid::from_str("bafyreie5cvv4h45feadgeuwhbcutmh6t2ceseocckahdoe6uat64zmz454").unwrap();
let mut tricky_map: BTreeMap<String, Cid> = Default::default();
- tricky_map.insert("".to_string(), cid1.clone());
- tricky_map.insert("jalapeño".to_string(), cid1.clone());
- tricky_map.insert("coöperative".to_string(), cid1.clone());
- tricky_map.insert("coüperative".to_string(), cid1.clone());
- tricky_map.insert("abc\x00".to_string(), cid1.clone());
+ tricky_map.insert("".to_string(), cid1);
+ tricky_map.insert("jalapeño".to_string(), cid1);
+ tricky_map.insert("coöperative".to_string(), cid1);
+ tricky_map.insert("coüperative".to_string(), cid1);
+ tricky_map.insert("abc\x00".to_string(), cid1);
assert_eq!(
repo.mst_from_map(&tricky_map).unwrap().to_string(),
"bafyreiecb33zh7r2sc3k2wthm6exwzfktof63kmajeildktqc25xj6qzx4"
@@ -74,12 +74,12 @@ fn test_trims_top() {
// NOTE: this test doesn't do much in this case of rust implementation
let mut trim_map: BTreeMap<String, Cid> = Default::default();
- trim_map.insert("com.example.record/40c73105b48f".to_string(), cid1.clone()); // level 0
- trim_map.insert("com.example.record/e99bf3ced34b".to_string(), cid1.clone()); // level 0
- trim_map.insert("com.example.record/893e6c08b450".to_string(), cid1.clone()); // level 0
- trim_map.insert("com.example.record/9cd8b6c0cc02".to_string(), cid1.clone()); // level 0
- trim_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1.clone()); // level 0
- trim_map.insert("com.example.record/a15e33ba0f6c".to_string(), cid1.clone()); // level 1
+ trim_map.insert("com.example.record/40c73105b48f".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/e99bf3ced34b".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/893e6c08b450".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/9cd8b6c0cc02".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/a15e33ba0f6c".to_string(), cid1); // level 1
let trim_before_cid = repo.mst_from_map(&trim_map).unwrap();
print_mst_keys(&mut repo.db, &trim_before_cid).unwrap();
assert_eq!(trim_before_cid.to_string(), l1root);
@@ -103,21 +103,21 @@ fn test_insertion() {
// TODO: actual mutation instead of rebuild from scratch
let mut insertion_map: BTreeMap<String, Cid> = Default::default();
- insertion_map.insert("com.example.record/403e2aeebfdb".to_string(), cid1.clone()); // A; level 0
- insertion_map.insert("com.example.record/40c73105b48f".to_string(), cid1.clone()); // B; level 0
- insertion_map.insert("com.example.record/645787eb4316".to_string(), cid1.clone()); // C; level 0
- insertion_map.insert("com.example.record/7ca4e61d6fbc".to_string(), cid1.clone()); // D; level 1
- insertion_map.insert("com.example.record/893e6c08b450".to_string(), cid1.clone()); // E; level 0
- insertion_map.insert("com.example.record/9cd8b6c0cc02".to_string(), cid1.clone()); // G; level 0
- insertion_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1.clone()); // H; level 0
- insertion_map.insert("com.example.record/dbea731be795".to_string(), cid1.clone()); // I; level 1
- insertion_map.insert("com.example.record/e2ef555433f2".to_string(), cid1.clone()); // J; level 0
- insertion_map.insert("com.example.record/e99bf3ced34b".to_string(), cid1.clone()); // K; level 0
- insertion_map.insert("com.example.record/f728ba61e4b6".to_string(), cid1.clone()); // L; level 0
+ insertion_map.insert("com.example.record/403e2aeebfdb".to_string(), cid1); // A; level 0
+ insertion_map.insert("com.example.record/40c73105b48f".to_string(), cid1); // B; level 0
+ insertion_map.insert("com.example.record/645787eb4316".to_string(), cid1); // C; level 0
+ insertion_map.insert("com.example.record/7ca4e61d6fbc".to_string(), cid1); // D; level 1
+ insertion_map.insert("com.example.record/893e6c08b450".to_string(), cid1); // E; level 0
+ insertion_map.insert("com.example.record/9cd8b6c0cc02".to_string(), cid1); // G; level 0
+ insertion_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1); // H; level 0
+ insertion_map.insert("com.example.record/dbea731be795".to_string(), cid1); // I; level 1
+ insertion_map.insert("com.example.record/e2ef555433f2".to_string(), cid1); // J; level 0
+ insertion_map.insert("com.example.record/e99bf3ced34b".to_string(), cid1); // K; level 0
+ insertion_map.insert("com.example.record/f728ba61e4b6".to_string(), cid1); // L; level 0
let insertion_before_cid = repo.mst_from_map(&insertion_map).unwrap();
assert_eq!(insertion_before_cid.to_string(), l1root);
- insertion_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1.clone());
+ insertion_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1);
let insertion_after_cid = repo.mst_from_map(&insertion_map).unwrap();
assert_eq!(insertion_after_cid.to_string(), l2root);
}
@@ -136,17 +136,17 @@ fn test_higher_layers() {
// TODO: actual mutation instead of rebuild from scratch
let mut higher_map: BTreeMap<String, Cid> = Default::default();
- higher_map.insert("com.example.record/403e2aeebfdb".to_string(), cid1.clone()); // A; level 0
- higher_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1.clone()); // C; level 0
+ higher_map.insert("com.example.record/403e2aeebfdb".to_string(), cid1); // A; level 0
+ higher_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1); // C; level 0
let higher_before_cid = repo.mst_from_map(&higher_map).unwrap();
assert_eq!(higher_before_cid.to_string(), l0root);
- higher_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1.clone()); // B; level 2
+ higher_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1); // B; level 2
let higher_after_cid = repo.mst_from_map(&higher_map).unwrap();
print_mst_keys(&mut repo.db, &higher_after_cid).unwrap();
assert_eq!(higher_after_cid.to_string(), l2root);
- higher_map.insert("com.example.record/fae7a851fbeb".to_string(), cid1.clone()); // D; level 1
+ higher_map.insert("com.example.record/fae7a851fbeb".to_string(), cid1); // D; level 1
let higher_after_cid = repo.mst_from_map(&higher_map).unwrap();
assert_eq!(higher_after_cid.to_string(), l2root2);
}