···1515$ cargo test && cargo fmt && cargo clippy
1616```
17171818+- prefer local error enums over generic string-y errors
1919+2020+- for jacquard's CoW-wrapped types:
2121+ - accept borrows like `fn do_thing(did: &Did<'_>)`.
2222+ - accept possibly-needing ownership like `fn do_thing(did: Did<'_>)`.
2323+ - accept full ownership like `fn do_thing(did: Did<'static>)`.
2424+1825- TODO: configure tangled CI to run these on PR
19262027
+1-1
src/examples/enqueue_resync.rs
···35353636 for raw in &args.dids {
3737 let did = Did::new_owned(raw.clone())?;
3838- let inserted = storage::repo::ensure_repo(&db, did.clone())?;
3838+ let inserted = storage::repo::ensure_repo(&db, &did)?;
3939 let item = ResyncItem {
4040 did: did.clone(),
4141 retry_count: 0,
+16-12
src/identity.rs
···1515//! fallback path built into jacquard-identity). When a PLC fallback is also
1616//! configured, any error from the primary resolver retries against it.
17171818+use jacquard_common::IntoStatic;
1819use std::sync::Arc;
1920use std::time::Duration;
2021···112113113114/// Capacity-bounded, TTL-expiring cache from DID strings to resolved identities.
114115struct IdentityCache {
115115- entries: Cache<String, Arc<CachedIdentity>>,
116116+ entries: Cache<Did<'static>, Arc<CachedIdentity>>,
116117 interner: UrlInterner,
117118}
118119···127128 }
128129 }
129130130130- fn get(&self, did: &str) -> Option<Arc<CachedIdentity>> {
131131- self.entries.get(&did.to_owned())
131131+ fn get(&self, did: &Did<'_>) -> Option<Arc<CachedIdentity>> {
132132+ self.entries.get(&did.clone().into_static())
132133 }
133134134134- fn insert(&self, did: &str, pds: Url, pubkey: PublicKey<'static>) -> Arc<CachedIdentity> {
135135+ fn insert(
136136+ &self,
137137+ did: Did<'static>,
138138+ pds: Url,
139139+ pubkey: PublicKey<'static>,
140140+ ) -> Arc<CachedIdentity> {
135141 let pds = self.interner.intern(pds);
136142 let identity = Arc::new(CachedIdentity { pds, pubkey });
137137- self.entries.insert(did.to_owned(), Arc::clone(&identity));
143143+ self.entries.insert(did, Arc::clone(&identity));
138144 identity
139145 }
140146141141- fn invalidate(&self, did: &str) {
142142- self.entries.invalidate(&did.to_owned());
147147+ fn invalidate(&self, did: &Did<'_>) {
148148+ self.entries.invalidate(&did.clone().into_static());
143149 }
144150}
145151···163169 /// Returns a cached [`CachedIdentity`] on cache hit; otherwise resolves
164170 /// via the primary (and optionally fallback) resolver and caches the result.
165171 pub async fn resolve(&self, did: &Did<'_>) -> Result<Arc<CachedIdentity>, IdentityError> {
166166- let did_str = did.as_str();
167167-168168- if let Some(cached) = self.cache.get(did_str) {
172172+ if let Some(cached) = self.cache.get(did) {
169173 metrics::counter!("lightrail_identity_resolution_total", "outcome" => "hit")
170174 .increment(1);
171175 return Ok(cached);
···175179 Ok((pds, pubkey)) => {
176180 metrics::counter!("lightrail_identity_resolution_total", "outcome" => "miss")
177181 .increment(1);
178178- Ok(self.cache.insert(did_str, pds, pubkey))
182182+ Ok(self.cache.insert(did.clone().into_static(), pds, pubkey))
179183 }
180184 Err(e) => {
181185 metrics::counter!("lightrail_identity_resolution_total", "outcome" => "error")
···191195 /// preceding commits for the same DID have been processed, so the next
192196 /// resolution fetches the updated key and PDS endpoint.
193197 pub fn invalidate_did(&self, did: &Did<'_>) {
194194- self.cache.invalidate(did.as_str());
198198+ self.cache.invalidate(did);
195199 }
196200197201 async fn resolve_uncached(
+1-1
src/server/get_repo_status.rs
···6666 let (info, prev) = tokio::task::spawn_blocking({
6767 let db = db.clone();
6868 let did = did.clone();
6969- move || crate::storage::repo::get(&db, did)
6969+ move || crate::storage::repo::get(&db, &did)
7070 })
7171 .await
7272 .map_err(|_| GetRepoStatusError::StorageError)??
+1-1
src/server/list_repos.rs
···80808181 let (entries, next) = tokio::task::spawn_blocking({
8282 let db = db.clone();
8383- move || crate::storage::repo::scan_repos(&db, cursor, limit)
8383+ move || crate::storage::repo::scan_repos(&db, cursor.as_ref(), limit)
8484 })
8585 .await
8686 .map_err(|_| ListReposError::StorageError)??;