don't
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: clippy

Signed-off-by: tjh <x@tjh.dev>

tjh.dev da2bdf65 8e359286

verified
+74 -20
+52 -4
crates/atproto/src/aturi.rs
··· 2 2 //! 3 3 //! <https://atproto.com/specs/at-uri-scheme> 4 4 //! 5 + use core::fmt; 6 + 7 + #[cfg(feature = "serde")] 5 8 use serde::{Deserialize, Serialize}; 6 9 7 10 use crate::{did::Did, handle::Handle, nsid::Nsid}; ··· 31 28 } 32 29 } 33 30 34 - pub fn collection_str(&self) -> Option<&str> { 35 - self.collection.map(|col| col.as_str()) 31 + pub const fn collection_str(&self) -> Option<&str> { 32 + match self.collection { 33 + Some(collection) => Some(collection.as_str()), 34 + None => None, 35 + } 36 36 } 37 37 } 38 38 ··· 43 37 pub enum Authority<'a> { 44 38 Did(&'a Did), 45 39 Handle(&'a Handle), 40 + } 41 + 42 + impl<'a> Authority<'a> { 43 + pub const fn is_did(&self) -> bool { 44 + matches!(self, Self::Did(_)) 45 + } 46 + 47 + pub const fn is_handle(&self) -> bool { 48 + matches!(self, Self::Handle(_)) 49 + } 50 + 51 + pub const fn as_str(&self) -> &str { 52 + match self { 53 + Self::Did(did) => did.as_str(), 54 + Self::Handle(handle) => handle.as_str(), 55 + } 56 + } 57 + } 58 + 59 + impl fmt::Display for Authority<'_> { 60 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 61 + f.write_str(self.as_str()) 62 + } 46 63 } 47 64 48 65 #[derive(Debug, thiserror::Error)] ··· 105 76 } 106 77 } 107 78 79 + impl fmt::Display for AtUri<'_> { 80 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 81 + write!(f, "at://{}", self.authority)?; 82 + if let Some(collection) = self.collection { 83 + write!(f, "/{collection}")?; 84 + if let Some(rkey) = self.rkey { 85 + write!(f, "/{rkey}")?; 86 + } 87 + } 88 + Ok(()) 89 + } 90 + } 91 + 92 + #[cfg(feature = "serde")] 108 93 impl<'de: 'a, 'a> Deserialize<'de> for AtUri<'a> { 109 94 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 110 95 where ··· 130 87 } 131 88 } 132 89 90 + #[cfg(feature = "serde")] 133 91 impl Serialize for AtUri<'_> { 134 92 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 135 93 where 136 94 S: serde::Serializer, 137 95 { 138 - unimplemented!() 96 + serializer.serialize_str(&self.to_string()) 139 97 } 140 98 } 141 99 ··· 148 104 fn valid_samples() { 149 105 let samples = ["at://foo.com/com.example.foo/123"]; 150 106 for sample in samples { 151 - assert!(AtUri::parse(sample).is_ok(), "{sample} should be valid"); 107 + let parsed = AtUri::parse(sample); 108 + assert!(parsed.is_ok(), "{sample} should be valid"); 109 + 110 + let s = parsed.unwrap().to_string(); 111 + assert_eq!(s, sample); 152 112 } 153 113 } 154 114
+12 -12
crates/identity/src/resolvers/direct.rs
··· 155 155 continue; 156 156 }; 157 157 158 - if let Some(old_did) = resolved_did.replace(did.clone()) { 159 - if old_did != did { 160 - tracing::error!( 161 - ?handle, 162 - ?did, 163 - ?old_did, 164 - "multiple conflicting DIDs found for handle" 165 - ); 166 - // @TODO Replace this with an error so we can retry with a 167 - // recursive dns resolver. 168 - return Ok(None); 169 - } 158 + if let Some(old_did) = resolved_did.replace(did.clone()) 159 + && old_did != did 160 + { 161 + tracing::error!( 162 + ?handle, 163 + ?did, 164 + ?old_did, 165 + "multiple conflicting DIDs found for handle" 166 + ); 167 + // @TODO Replace this with an error so we can retry with a 168 + // recursive dns resolver. 169 + return Ok(None); 170 170 } 171 171 } 172 172 }
+2 -2
crates/knot/src/model/knot_state.rs
··· 197 197 continue; 198 198 }; 199 199 200 - db.upsert_public_key(&did, &rkey, &rev, &record.cid, &public_key) 200 + db.upsert_public_key(&did, rkey, &rev, &record.cid, &public_key) 201 201 .await?; 202 202 } 203 203 ··· 258 258 } 259 259 260 260 if let Ok(true) = db 261 - .insert_repository(&did, &rkey, &rev, &record.cid, &repo) 261 + .insert_repository(&did, rkey, &rev, &record.cid, &repo) 262 262 .await 263 263 { 264 264 let path = base.join(did.as_str()).join(rkey);
+7 -1
crates/knot/src/model/nicediff.rs
··· 18 18 #[error("{0}")] 19 19 Io(#[from] std::io::Error), 20 20 #[error("{0}")] 21 - Platform(#[from] gix::diff::blob::platform::set_resource::Error), 21 + Platform(Box<gix::diff::blob::platform::set_resource::Error>), 22 22 #[error("{0}")] 23 23 Diff(#[from] gix::object::blob::diff::lines::Error<SubError>), 24 + } 25 + 26 + impl From<gix::diff::blob::platform::set_resource::Error> for Error { 27 + fn from(value: gix::diff::blob::platform::set_resource::Error) -> Self { 28 + Self::Platform(Box::new(value)) 29 + } 24 30 } 25 31 26 32 #[derive(Debug, thiserror::Error)]
+1 -1
crates/knot/src/services/atrepo.rs
··· 18 18 Callback(E), 19 19 } 20 20 21 - pub async fn fetch_collection<'de, F, E>( 21 + pub async fn fetch_collection<F, E>( 22 22 resolver: &identity::Resolver, 23 23 http: &reqwest::Client, 24 24 did: &Did,