don't
5
fork

Configure Feed

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

style: rename `OwnedDid` to `DidBuf`

As `Did` is loosely modelled on `std::path::Path`, it makes sense to
name the owned version similarly to `std::path::PathBuf`.

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

tjh 3cb3e88f 7b6fd3ee

+215 -215
+4 -4
.sqlx/query-048836a40ab4c498fcd5284e44dd515c40f0a9f357537120421bd2d9bd8c4ab5.json .sqlx/query-2b2e0ee2a5424c91f88da740cc72e860e9a10dfd58a15ed5a3f5da48c4211293.json
··· 1 1 { 2 2 "db_name": "SQLite", 3 - "query": "SELECT repo_did as \"repo_did: OwnedDid\", repo_rkey, subject as \"subject: OwnedDid\" FROM repository_collaborator WHERE repo_did = ? AND repo_rkey = ? AND subject = ?", 3 + "query": "SELECT repo_did as \"repo_did: DidBuf\", repo_rkey, subject as \"subject: DidBuf\" FROM repository_collaborator WHERE repo_did = ? AND repo_rkey = ? AND subject = ?", 4 4 "describe": { 5 5 "columns": [ 6 6 { 7 - "name": "repo_did: OwnedDid", 7 + "name": "repo_did: DidBuf", 8 8 "ordinal": 0, 9 9 "type_info": "Text" 10 10 }, ··· 14 14 "type_info": "Text" 15 15 }, 16 16 { 17 - "name": "subject: OwnedDid", 17 + "name": "subject: DidBuf", 18 18 "ordinal": 2, 19 19 "type_info": "Text" 20 20 } ··· 28 28 false 29 29 ] 30 30 }, 31 - "hash": "048836a40ab4c498fcd5284e44dd515c40f0a9f357537120421bd2d9bd8c4ab5" 31 + "hash": "2b2e0ee2a5424c91f88da740cc72e860e9a10dfd58a15ed5a3f5da48c4211293" 32 32 }
+20
.sqlx/query-05bc927acc20445d1940ae6d725c112a40b3c69acbd54565fcfe8e3671543288.json
··· 1 + { 2 + "db_name": "SQLite", 3 + "query": "DELETE FROM knot_member WHERE rkey = ? AND rev <= ? RETURNING subject AS \"subject: DidBuf\"", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "name": "subject: DidBuf", 8 + "ordinal": 0, 9 + "type_info": "Text" 10 + } 11 + ], 12 + "parameters": { 13 + "Right": 2 14 + }, 15 + "nullable": [ 16 + false 17 + ] 18 + }, 19 + "hash": "05bc927acc20445d1940ae6d725c112a40b3c69acbd54565fcfe8e3671543288" 20 + }
-20
.sqlx/query-238fca839c4a27ef8fe65555fe0c17feca3ee0c31f5d32fe20e72f3c15609058.json
··· 1 - { 2 - "db_name": "SQLite", 3 - "query": "DELETE FROM repository_collaborator WHERE did = ? AND rkey = ? AND rev <= ? RETURNING subject AS \"subject: OwnedDid\"", 4 - "describe": { 5 - "columns": [ 6 - { 7 - "name": "subject: OwnedDid", 8 - "ordinal": 0, 9 - "type_info": "Text" 10 - } 11 - ], 12 - "parameters": { 13 - "Right": 3 14 - }, 15 - "nullable": [ 16 - false 17 - ] 18 - }, 19 - "hash": "238fca839c4a27ef8fe65555fe0c17feca3ee0c31f5d32fe20e72f3c15609058" 20 - }
+20
.sqlx/query-477a5f49f0182f55ab0c76f58bd0487eca08865468a0e512023811d369defcd7.json
··· 1 + { 2 + "db_name": "SQLite", 3 + "query": "SELECT DISTINCT subject AS \"subject: DidBuf\" FROM knot_member UNION SELECT DISTINCT subject AS \"subject: DidBuf\" FROM repository_collaborator", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "name": "subject: DidBuf", 8 + "ordinal": 0, 9 + "type_info": "Text" 10 + } 11 + ], 12 + "parameters": { 13 + "Right": 0 14 + }, 15 + "nullable": [ 16 + false 17 + ] 18 + }, 19 + "hash": "477a5f49f0182f55ab0c76f58bd0487eca08865468a0e512023811d369defcd7" 20 + }
+9 -3
.sqlx/query-5f53be4afc405307a2610d6ae874f0b4adb3ddd28216a5f2262b2b39e78827b4.json .sqlx/query-e603b27249735f97e81d76c7983f4ff1f7a1482badd5a7549ad936bd91c17cc5.json
··· 1 1 { 2 2 "db_name": "SQLite", 3 - "query": "DELETE FROM public_key WHERE did = ? AND rkey = ? AND rev <= ? RETURNING did AS \"did: OwnedDid\", rkey, rev, cid", 3 + "query": "DELETE FROM repository WHERE did = ? AND rkey = ? AND rev <= ? RETURNING did AS \"did: DidBuf\", rkey, rev, cid, name", 4 4 "describe": { 5 5 "columns": [ 6 6 { 7 - "name": "did: OwnedDid", 7 + "name": "did: DidBuf", 8 8 "ordinal": 0, 9 9 "type_info": "Text" 10 10 }, ··· 22 22 "name": "cid", 23 23 "ordinal": 3, 24 24 "type_info": "Text" 25 + }, 26 + { 27 + "name": "name", 28 + "ordinal": 4, 29 + "type_info": "Text" 25 30 } 26 31 ], 27 32 "parameters": { ··· 36 31 false, 37 32 false, 38 33 false, 34 + false, 39 35 false 40 36 ] 41 37 }, 42 - "hash": "5f53be4afc405307a2610d6ae874f0b4adb3ddd28216a5f2262b2b39e78827b4" 38 + "hash": "e603b27249735f97e81d76c7983f4ff1f7a1482badd5a7549ad936bd91c17cc5" 43 39 }
+3 -9
.sqlx/query-75c9eb329fed46fa5a22c1892559186a9f64dd2308efa272fb9597f4975fcc2c.json .sqlx/query-35551fe1810ba130902d2c1c2205748148c2634fe3864586fc55f47c02e0a717.json
··· 1 1 { 2 2 "db_name": "SQLite", 3 - "query": "DELETE FROM repository WHERE did = ? AND rkey = ? AND rev <= ? RETURNING did AS \"did: OwnedDid\", rkey, rev, cid, name", 3 + "query": "DELETE FROM public_key WHERE did = ? AND rkey = ? AND rev <= ? RETURNING did AS \"did: DidBuf\", rkey, rev, cid", 4 4 "describe": { 5 5 "columns": [ 6 6 { 7 - "name": "did: OwnedDid", 7 + "name": "did: DidBuf", 8 8 "ordinal": 0, 9 9 "type_info": "Text" 10 10 }, ··· 22 22 "name": "cid", 23 23 "ordinal": 3, 24 24 "type_info": "Text" 25 - }, 26 - { 27 - "name": "name", 28 - "ordinal": 4, 29 - "type_info": "Text" 30 25 } 31 26 ], 32 27 "parameters": { ··· 31 36 false, 32 37 false, 33 38 false, 34 - false, 35 39 false 36 40 ] 37 41 }, 38 - "hash": "75c9eb329fed46fa5a22c1892559186a9f64dd2308efa272fb9597f4975fcc2c" 42 + "hash": "35551fe1810ba130902d2c1c2205748148c2634fe3864586fc55f47c02e0a717" 39 43 }
+3 -3
.sqlx/query-76f6999bdc440d66e273756de1dc8df3ab181f79430e8569cfc7c6ef1b1c64a6.json .sqlx/query-82f7026064a72d4cc786b577d8a3016895cc95bdbb0cb31230cf807a55a0ab5b.json
··· 1 1 { 2 2 "db_name": "SQLite", 3 - "query": "SELECT subject AS \"subject: OwnedDid\" FROM knot_member ORDER BY rkey, rev", 3 + "query": "SELECT subject AS \"subject: DidBuf\" FROM knot_member ORDER BY rkey, rev", 4 4 "describe": { 5 5 "columns": [ 6 6 { 7 - "name": "subject: OwnedDid", 7 + "name": "subject: DidBuf", 8 8 "ordinal": 0, 9 9 "type_info": "Text" 10 10 } ··· 16 16 false 17 17 ] 18 18 }, 19 - "hash": "76f6999bdc440d66e273756de1dc8df3ab181f79430e8569cfc7c6ef1b1c64a6" 19 + "hash": "82f7026064a72d4cc786b577d8a3016895cc95bdbb0cb31230cf807a55a0ab5b" 20 20 }
+4 -4
.sqlx/query-83fcec65ae89457c3ae22d9219814f526d1e94800fca973d06f8128b5cef2cce.json .sqlx/query-d8d1a00be907c761d354d53deb6aa6ae2e5aab6aec2a24470f13a24777794c50.json
··· 1 1 { 2 2 "db_name": "SQLite", 3 - "query": "SELECT repo_did as \"repo_did: OwnedDid\", repo_rkey, subject as \"subject: OwnedDid\" FROM repository_collaborator WHERE did = ? AND rkey = ?", 3 + "query": "SELECT repo_did as \"repo_did: DidBuf\", repo_rkey, subject as \"subject: DidBuf\" FROM repository_collaborator WHERE did = ? AND rkey = ?", 4 4 "describe": { 5 5 "columns": [ 6 6 { 7 - "name": "repo_did: OwnedDid", 7 + "name": "repo_did: DidBuf", 8 8 "ordinal": 0, 9 9 "type_info": "Text" 10 10 }, ··· 14 14 "type_info": "Text" 15 15 }, 16 16 { 17 - "name": "subject: OwnedDid", 17 + "name": "subject: DidBuf", 18 18 "ordinal": 2, 19 19 "type_info": "Text" 20 20 } ··· 28 28 false 29 29 ] 30 30 }, 31 - "hash": "83fcec65ae89457c3ae22d9219814f526d1e94800fca973d06f8128b5cef2cce" 31 + "hash": "d8d1a00be907c761d354d53deb6aa6ae2e5aab6aec2a24470f13a24777794c50" 32 32 }
+3 -3
.sqlx/query-8717187358c87236b24073b53c9df622c60c6470c03029083ef52d6419b203be.json .sqlx/query-3f1b52e99cb00948ed0c1bd264b41d188f4e756b2da4204a9ea44b06fe14fdd7.json
··· 1 1 { 2 2 "db_name": "SQLite", 3 - "query": "SELECT subject as \"subject: OwnedDid\" FROM knot_member WHERE subject = ? LIMIT 1", 3 + "query": "SELECT subject as \"subject: DidBuf\" FROM knot_member WHERE subject = ? LIMIT 1", 4 4 "describe": { 5 5 "columns": [ 6 6 { 7 - "name": "subject: OwnedDid", 7 + "name": "subject: DidBuf", 8 8 "ordinal": 0, 9 9 "type_info": "Text" 10 10 } ··· 16 16 false 17 17 ] 18 18 }, 19 - "hash": "8717187358c87236b24073b53c9df622c60c6470c03029083ef52d6419b203be" 19 + "hash": "3f1b52e99cb00948ed0c1bd264b41d188f4e756b2da4204a9ea44b06fe14fdd7" 20 20 }
-20
.sqlx/query-8e78a6a80756f675c3c67a5b4b590db379386d9ec49b95655895f7d488f4fa61.json
··· 1 - { 2 - "db_name": "SQLite", 3 - "query": "SELECT DISTINCT subject AS \"subject: OwnedDid\" FROM knot_member UNION SELECT DISTINCT subject AS \"subject: OwnedDid\" FROM repository_collaborator", 4 - "describe": { 5 - "columns": [ 6 - { 7 - "name": "subject: OwnedDid", 8 - "ordinal": 0, 9 - "type_info": "Text" 10 - } 11 - ], 12 - "parameters": { 13 - "Right": 0 14 - }, 15 - "nullable": [ 16 - false 17 - ] 18 - }, 19 - "hash": "8e78a6a80756f675c3c67a5b4b590db379386d9ec49b95655895f7d488f4fa61" 20 - }
+20
.sqlx/query-9a3ec9359f9111463a10867542f935c08327a51d126200438858c06d97beb163.json
··· 1 + { 2 + "db_name": "SQLite", 3 + "query": "DELETE FROM repository_collaborator WHERE did = ? AND rkey = ? AND rev <= ? RETURNING subject AS \"subject: DidBuf\"", 4 + "describe": { 5 + "columns": [ 6 + { 7 + "name": "subject: DidBuf", 8 + "ordinal": 0, 9 + "type_info": "Text" 10 + } 11 + ], 12 + "parameters": { 13 + "Right": 3 14 + }, 15 + "nullable": [ 16 + false 17 + ] 18 + }, 19 + "hash": "9a3ec9359f9111463a10867542f935c08327a51d126200438858c06d97beb163" 20 + }
-20
.sqlx/query-d5bea4ab2280d11b6d5cfc7a6140ac43c9271a3848595d43d00594bcbf82fe71.json
··· 1 - { 2 - "db_name": "SQLite", 3 - "query": "DELETE FROM knot_member WHERE rkey = ? AND rev <= ? RETURNING subject AS \"subject: OwnedDid\"", 4 - "describe": { 5 - "columns": [ 6 - { 7 - "name": "subject: OwnedDid", 8 - "ordinal": 0, 9 - "type_info": "Text" 10 - } 11 - ], 12 - "parameters": { 13 - "Right": 2 14 - }, 15 - "nullable": [ 16 - false 17 - ] 18 - }, 19 - "hash": "d5bea4ab2280d11b6d5cfc7a6140ac43c9271a3848595d43d00594bcbf82fe71" 20 - }
+3 -3
crates/gordian-auth/src/jwt.rs
··· 1 1 use core::fmt; 2 2 3 3 use data_encoding::BASE64URL_NOPAD as Encoding; 4 - use gordian_types::{Nsid, OwnedDid}; 4 + use gordian_types::{Nsid, DidBuf}; 5 5 use serde::{Deserialize, Serialize, de::DeserializeOwned}; 6 6 7 7 use crate::verification_key::{Unspecified, VerificationKey}; ··· 66 66 pub struct Claims { 67 67 /// Account DID associated with the service that the request is being 68 68 /// sent to. 69 - pub iss: OwnedDid, 69 + pub iss: DidBuf, 70 70 71 71 /// Service DID associated with the service that the request is being 72 72 /// sent to. 73 - pub aud: OwnedDid, 73 + pub aud: DidBuf, 74 74 75 75 /// Token creation time as a UNIX timestamp. 76 76 pub iat: i64,
+2 -2
crates/gordian-cred/src/commands/git_credential.rs
··· 2 2 use data_encoding::{BASE32HEX_NOPAD, BASE64URL_NOPAD}; 3 3 use exn::{Exn, ResultExt as _}; 4 4 use gordian_auth::jwt::{Algorithm, Curve, Header}; 5 - use gordian_types::OwnedDid; 5 + use gordian_types::DidBuf; 6 6 use owo_colors::{OwoColorize, Stream::Stderr}; 7 7 use ssh_agent_client_rs::{Client, Identity}; 8 8 use ssh_key::public::{EcdsaPublicKey, KeyData}; ··· 165 165 // // We found a key, construct our JWT claims. 166 166 let iss = account_did.clone(); 167 167 let aud = format!("did:web:{knot}") 168 - .parse::<OwnedDid>() 168 + .parse::<DidBuf>() 169 169 .or_raise(err)?; 170 170 let iat = OffsetDateTime::now_utc().unix_timestamp(); 171 171 let exp = iat + 45;
+3 -3
crates/gordian-cred/src/config.rs
··· 1 1 use core::{error, fmt}; 2 2 use directories::ProjectDirs; 3 3 use exn::{Exn, OptionExt, ResultExt}; 4 - use gordian_types::OwnedDid; 4 + use gordian_types::DidBuf; 5 5 use serde::{Deserialize, Serialize}; 6 6 use std::{ 7 7 borrow::Cow, ··· 19 19 #[derive(Debug, Default, Deserialize, Serialize)] 20 20 pub struct Configuration { 21 21 #[serde(default)] 22 - pub active_account: Option<OwnedDid>, 22 + pub active_account: Option<DidBuf>, 23 23 24 24 #[serde(default)] 25 - pub keys: HashMap<OwnedDid, HashSet<PublicKey>>, 25 + pub keys: HashMap<DidBuf, HashSet<PublicKey>>, 26 26 } 27 27 28 28 #[derive(Debug)]
+3 -3
crates/gordian-identity/src/document.rs
··· 1 - use gordian_types::did::OwnedDid; 1 + use gordian_types::did::DidBuf; 2 2 use serde::{Deserialize, Serialize}; 3 3 use url::Url; 4 4 ··· 8 8 #[serde(rename_all = "camelCase")] 9 9 Multikey { 10 10 id: String, 11 - controller: OwnedDid, 11 + controller: DidBuf, 12 12 public_key_multibase: String, 13 13 }, 14 14 } ··· 39 39 pub struct DidDocument { 40 40 #[serde(default, rename = "@context")] 41 41 pub context: Vec<Url>, 42 - pub id: OwnedDid, 42 + pub id: DidBuf, 43 43 pub also_known_as: Vec<Url>, 44 44 pub verification_method: Vec<VerificationMethod>, 45 45 pub service: Vec<Service>,
+8 -8
crates/gordian-identity/src/lib.rs
··· 5 5 use std::sync::Arc; 6 6 7 7 use futures_util::{FutureExt as _, future::BoxFuture}; 8 - use gordian_types::did::OwnedDid; 8 + use gordian_types::did::DidBuf; 9 9 10 10 pub use document::{DidDocument, Service, VerificationMethod}; 11 11 pub use gordian_types::did::Did; ··· 21 21 fn resolve<'s: 'a, 'a>( 22 22 &'s self, 23 23 ident: &'a str, 24 - ) -> BoxFuture<'a, Result<(OwnedDid, DidDocument), ResolveError>> { 25 - if let Ok(did) = ident.parse::<OwnedDid>() { 24 + ) -> BoxFuture<'a, Result<(DidBuf, DidDocument), ResolveError>> { 25 + if let Ok(did) = ident.parse::<DidBuf>() { 26 26 async { 27 27 let doc = self.resolve_did(&did).await?; 28 28 let handle = doc.primary_alias().ok_or(ResolveError::InvalidDocument)?; ··· 71 71 fn resolve_handle<'s: 'h, 'h>( 72 72 &'s self, 73 73 handle: &'h str, 74 - ) -> BoxFuture<'h, Result<OwnedDid, ResolveError>>; 74 + ) -> BoxFuture<'h, Result<DidBuf, ResolveError>>; 75 75 76 76 /// Resolve a DID to DID document. 77 77 /// ··· 148 148 /// Returns a error if `ident` cannot be resolved. This included bi-directional resolution 149 149 /// errors. 150 150 /// 151 - pub async fn resolve(&self, ident: &str) -> Result<(OwnedDid, DidDocument), ResolveError> { 151 + pub async fn resolve(&self, ident: &str) -> Result<(DidBuf, DidDocument), ResolveError> { 152 152 let ident = ident.trim_start_matches('@'); 153 153 self.inner.resolve(ident).await 154 154 } ··· 160 160 /// Returns a error if `handle` cannot be resolved to a DID. 161 161 /// 162 162 #[inline] 163 - pub async fn resolve_handle(&self, handle: &str) -> Result<OwnedDid, ResolveError> { 163 + pub async fn resolve_handle(&self, handle: &str) -> Result<DidBuf, ResolveError> { 164 164 let handle = handle.trim_start_matches('@'); 165 165 self.inner.resolve_handle(handle).await 166 166 } ··· 186 186 fn resolve<'s: 'i, 'i>( 187 187 &'s self, 188 188 ident: &'i str, 189 - ) -> BoxFuture<'i, Result<(OwnedDid, DidDocument), ResolveError>> { 189 + ) -> BoxFuture<'i, Result<(DidBuf, DidDocument), ResolveError>> { 190 190 Self::resolve(self, ident).boxed() 191 191 } 192 192 193 193 fn resolve_handle<'s: 'h, 'h>( 194 194 &'s self, 195 195 handle: &'h str, 196 - ) -> BoxFuture<'h, Result<OwnedDid, ResolveError>> { 196 + ) -> BoxFuture<'h, Result<DidBuf, ResolveError>> { 197 197 Self::resolve_handle(self, handle).boxed() 198 198 } 199 199
+5 -5
crates/gordian-identity/src/resolvers/direct.rs
··· 1 1 use std::borrow::Cow; 2 2 3 3 use futures_util::{FutureExt as _, future::BoxFuture}; 4 - use gordian_types::did::OwnedDid; 4 + use gordian_types::did::DidBuf; 5 5 use hickory_resolver::name_server::TokioConnectionProvider; 6 6 use hickory_resolver::{ 7 7 ResolveError as DnsResolveError, Resolver as DnsClient, TokioResolver, ··· 43 43 fn resolve_handle<'s: 'h, 'h>( 44 44 &'s self, 45 45 handle: &'h str, 46 - ) -> BoxFuture<'h, Result<OwnedDid, ResolveError>> { 46 + ) -> BoxFuture<'h, Result<DidBuf, ResolveError>> { 47 47 let dns = resolve_handle_dns(&self.dns, handle); 48 48 let http = resolve_handle_http(&self.http, handle); 49 49 ··· 147 147 async fn resolve_handle_dns<R>( 148 148 client: &DnsClient<R>, 149 149 handle: &str, 150 - ) -> Result<Option<OwnedDid>, DnsResolveError> 150 + ) -> Result<Option<DidBuf>, DnsResolveError> 151 151 where 152 152 R: ConnectionProvider, 153 153 { ··· 161 161 let Some(txt_did) = txt.strip_prefix("did=") else { 162 162 continue; 163 163 }; 164 - let Ok(did) = txt_did.parse::<OwnedDid>() else { 164 + let Ok(did) = txt_did.parse::<DidBuf>() else { 165 165 continue; 166 166 }; 167 167 ··· 187 187 async fn resolve_handle_http( 188 188 client: &HttpClient, 189 189 handle: &str, 190 - ) -> Result<Option<OwnedDid>, reqwest::Error> { 190 + ) -> Result<Option<DidBuf>, reqwest::Error> { 191 191 let response = client 192 192 .get(format!("https://{handle}/.well-known/atproto-did")) 193 193 .send()
+4 -4
crates/gordian-identity/src/resolvers/memcache.rs
··· 1 1 use std::{sync::Arc, time::Duration}; 2 2 3 3 use futures_util::{FutureExt as _, TryFutureExt as _, future::BoxFuture}; 4 - use gordian_types::OwnedDid; 4 + use gordian_types::DidBuf; 5 5 use moka::future::{Cache, CacheBuilder}; 6 6 7 7 use crate::{Did, DidDocument, ResolveError, ResolveIdentity}; ··· 15 15 /// An indentity resolver with an in-memory cache. 16 16 #[derive(Debug)] 17 17 pub struct MemcacheResolver { 18 - did_cache: Cache<Box<str>, OwnedDid>, 19 - doc_cache: Cache<OwnedDid, DidDocument>, 18 + did_cache: Cache<Box<str>, DidBuf>, 19 + doc_cache: Cache<DidBuf, DidDocument>, 20 20 inner: Box<dyn ResolveIdentity + Send + 'static>, 21 21 } 22 22 ··· 56 56 fn resolve_handle<'s: 'h, 'h>( 57 57 &'s self, 58 58 handle: &'h str, 59 - ) -> BoxFuture<'h, Result<OwnedDid, ResolveError>> { 59 + ) -> BoxFuture<'h, Result<DidBuf, ResolveError>> { 60 60 self.did_cache 61 61 .try_get_with(handle.into(), self.inner.resolve_handle(handle)) 62 62 .map_err(Arc::unwrap_or_clone)
+6 -6
crates/gordian-jetstream/src/client.rs
··· 6 6 task::JetstreamTaskError, 7 7 }; 8 8 use bytes::Bytes; 9 - use gordian_types::OwnedDid; 9 + use gordian_types::DidBuf; 10 10 use std::sync::{Arc, Mutex}; 11 11 use tokio::sync::oneshot; 12 12 use tokio_util::sync::{CancellationToken, DropGuard}; ··· 45 45 /// 46 46 /// Panics if the [`Mutex`] for the client options has been poisoned. 47 47 /// 48 - pub async fn add_did(&self, did: impl Into<OwnedDid>) -> Result<(), JetstreamClientError> { 48 + pub async fn add_did(&self, did: impl Into<DidBuf>) -> Result<(), JetstreamClientError> { 49 49 if self.options.lock().unwrap().add_did(did.into())? { 50 50 // The DID is new to the client, notify the task to update. 51 51 self.update_task().await?; ··· 63 63 /// 64 64 /// Panics if the [`Mutex`] for the client options has been poisoned. 65 65 /// 66 - pub async fn remove_did(&self, did: impl Into<OwnedDid>) -> Result<(), JetstreamClientError> { 66 + pub async fn remove_did(&self, did: impl Into<DidBuf>) -> Result<(), JetstreamClientError> { 67 67 if self.options.lock().unwrap().remove_did(&did.into()) { 68 68 self.update_task().await?; 69 69 } ··· 173 173 #[error("Error in jetstream client task: {0}")] 174 174 TaskError(#[from] JetstreamTaskError), 175 175 #[error("DID filter exceeds maximum size")] 176 - TooManyDids(OwnedDid), 176 + TooManyDids(DidBuf), 177 177 #[error("Collection filter exceeds maximum size")] 178 178 TooManyCollections(Box<Nsid>), 179 179 } ··· 190 190 } 191 191 } 192 192 193 - impl From<OwnedDid> for JetstreamClientError { 194 - fn from(value: OwnedDid) -> Self { 193 + impl From<DidBuf> for JetstreamClientError { 194 + fn from(value: DidBuf) -> Self { 195 195 Self::TooManyDids(value) 196 196 } 197 197 }
+4 -4
crates/gordian-jetstream/src/subscriber_options.rs
··· 1 1 use std::collections::HashSet; 2 2 3 - use gordian_types::OwnedDid; 3 + use gordian_types::DidBuf; 4 4 use serde::{Deserialize, Serialize}; 5 5 6 6 use crate::{Did, Nsid}; ··· 30 30 /// Repository DIDs to filter which records are received. 31 31 /// 32 32 /// Maximum: `10_000` 33 - pub wanted_dids: HashSet<OwnedDid>, 33 + pub wanted_dids: HashSet<DidBuf>, 34 34 35 35 /// Maximum message size in bytes the subscriber wants to receive. 36 36 /// ··· 79 79 /// Returns an error if adding `did` would cause [`SubscriberOptions`] to exceed the maximum 80 80 /// number of subscribed DIDs. 81 81 /// 82 - pub fn add_did(&mut self, did: OwnedDid) -> Result<bool, OwnedDid> { 82 + pub fn add_did(&mut self, did: DidBuf) -> Result<bool, DidBuf> { 83 83 if self.wanted_dids.len() == MAX_WANTED_DIDS && !self.wanted_dids.contains(&did) { 84 84 return Err(did); 85 85 } ··· 218 218 #[serde(rename_all = "camelCase")] 219 219 pub struct OptionsUpdate<'a> { 220 220 wanted_collections: &'a HashSet<Box<Nsid>>, 221 - wanted_dids: &'a HashSet<OwnedDid>, 221 + wanted_dids: &'a HashSet<DidBuf>, 222 222 #[serde(with = "max_message_size")] 223 223 max_message_size_bytes: &'a i64, 224 224 }
+2 -2
crates/gordian-knot/src/cli/hook.rs
··· 8 8 9 9 use axum::http::{HeaderMap, HeaderName, HeaderValue}; 10 10 use bytes::Bytes; 11 - use gordian_types::OwnedDid; 11 + use gordian_types::DidBuf; 12 12 use reqwest::header::InvalidHeaderName; 13 13 use url::Url; 14 14 ··· 24 24 25 25 /// DID of the repository owner. 26 26 #[arg(long, env = gordian_knot::private::ENV_REPO_DID)] 27 - pub repo_did: OwnedDid, 27 + pub repo_did: DidBuf, 28 28 29 29 /// Record key of the repository. 30 30 #[arg(long, env = gordian_knot::private::ENV_REPO_RKEY)]
+2 -2
crates/gordian-knot/src/cli/serve.rs
··· 13 13 }, 14 14 services::database::DataStore, 15 15 }; 16 - use gordian_types::OwnedDid; 16 + use gordian_types::DidBuf; 17 17 use tokio::{net::TcpListener, signal, task::JoinSet}; 18 18 use tokio_util::sync::CancellationToken; 19 19 use tower::ServiceBuilder; ··· 38 38 39 39 /// Handle or DID of the knot owner. 40 40 #[arg(long, short, env = "KNOT_OWNER")] 41 - pub owner: OwnedDid, 41 + pub owner: DidBuf, 42 42 43 43 /// Base path for repositories. 44 44 #[arg(long, short, value_hint = ValueHint::DirPath, env = "KNOT_REPO_BASE")]
+3 -3
crates/gordian-knot/src/mock.rs
··· 3 3 services::database::DataStore, 4 4 }; 5 5 use gordian_identity::Resolver; 6 - use gordian_types::OwnedDid; 6 + use gordian_types::DidBuf; 7 7 8 8 pub use gordian_pds::Pds; 9 9 ··· 21 21 axum::serve(listener, pds_api).await.unwrap(); 22 22 }); 23 23 24 - let owner_did = OwnedDid::parse(owner_did).expect("owner DID must be valid"); 25 - let instance = OwnedDid::parse(format!("did:web:{instance_name}")) 24 + let owner_did = DidBuf::parse(owner_did).expect("owner DID must be valid"); 25 + let instance = DidBuf::parse(format!("did:web:{instance_name}")) 26 26 .expect("instance name should form a valid DID"); 27 27 28 28 let database = DataStore::new(pool);
+4 -4
crates/gordian-knot/src/model/config.rs
··· 1 1 //! Knot configuration. 2 2 use gix::bstr::BString; 3 - use gordian_types::{Did, OwnedDid}; 3 + use gordian_types::{Did, DidBuf}; 4 4 use rustc_hash::FxHashSet; 5 5 use std::{ 6 6 path::{Path, PathBuf}, ··· 27 27 28 28 #[derive(Debug)] 29 29 pub struct KnotConfiguration { 30 - pub owner: OwnedDid, 31 - pub instance: OwnedDid, 30 + pub owner: DidBuf, 31 + pub instance: DidBuf, 32 32 pub repo_path: PathBuf, 33 33 pub git_config: PathBuf, 34 34 pub readmes: FxHashSet<BString>, ··· 44 44 } 45 45 46 46 impl KnotConfiguration { 47 - pub fn new<P>(owner: OwnedDid, instance: OwnedDid, base: P) -> Self 47 + pub fn new<P>(owner: DidBuf, instance: DidBuf, base: P) -> Self 48 48 where 49 49 P: AsRef<Path>, 50 50 {
+2 -2
crates/gordian-knot/src/private.rs
··· 9 9 use gordian_lexicon::sh_tangled::git::{ 10 10 CommitCount, CommitCountBreakdown, Language, LanguageBreakdown, Meta, RefUpdate, 11 11 }; 12 - use gordian_types::OwnedDid; 12 + use gordian_types::DidBuf; 13 13 use serde::{Deserialize, Serialize}; 14 14 use time::OffsetDateTime; 15 15 use tokio_rayon::AsyncThreadPool as _; ··· 85 85 } 86 86 87 87 /// Extracts the 'X-Gordian-User-Did' header from a request. 88 - pub struct ActorDid(pub OwnedDid); 88 + pub struct ActorDid(pub DidBuf); 89 89 90 90 impl<S: Sync> FromRequestParts<S> for ActorDid { 91 91 type Rejection = (StatusCode, Cow<'static, str>);
+15 -15
crates/gordian-knot/src/services/database.rs
··· 5 5 use gordian_auth::jwt; 6 6 use gordian_jetstream::Value; 7 7 use gordian_lexicon::sh_tangled::{PublicKey, knot::Member, repo::Repo}; 8 - use gordian_types::{Did, OwnedDid}; 8 + use gordian_types::{Did, DidBuf}; 9 9 use serde::Serialize; 10 10 use sqlx::{SqlitePool, error::ErrorKind}; 11 11 use time::OffsetDateTime; ··· 62 62 Ok(()) 63 63 } 64 64 65 - pub fn knot_members(&self) -> BoxStream<'_, Result<OwnedDid, DataStoreError>> { 66 - sqlx::query!(r#"SELECT subject AS "subject: OwnedDid" FROM knot_member ORDER BY rkey, rev"#) 65 + pub fn knot_members(&self) -> BoxStream<'_, Result<DidBuf, DataStoreError>> { 66 + sqlx::query!(r#"SELECT subject AS "subject: DidBuf" FROM knot_member ORDER BY rkey, rev"#) 67 67 .fetch(&self.db) 68 68 .map(|record| Ok(record?.subject)) 69 69 .boxed() 70 70 } 71 71 72 72 /// Get all the knot members and repository collaborators associated with the knot. 73 - pub fn members(&self) -> BoxStream<'_, Result<OwnedDid, DataStoreError>> { 74 - sqlx::query!(r#"SELECT DISTINCT subject AS "subject: OwnedDid" FROM knot_member UNION SELECT DISTINCT subject AS "subject: OwnedDid" FROM repository_collaborator"#) 73 + pub fn members(&self) -> BoxStream<'_, Result<DidBuf, DataStoreError>> { 74 + sqlx::query!(r#"SELECT DISTINCT subject AS "subject: DidBuf" FROM knot_member UNION SELECT DISTINCT subject AS "subject: DidBuf" FROM repository_collaborator"#) 75 75 .fetch(&self.db) 76 76 .map(|record| Ok(record?.subject)) 77 77 .boxed() ··· 121 121 &self, 122 122 rkey: &str, 123 123 rev: &str, 124 - ) -> Result<Option<OwnedDid>, DataStoreError> { 124 + ) -> Result<Option<DidBuf>, DataStoreError> { 125 125 let result = sqlx::query!( 126 - r#"DELETE FROM knot_member WHERE rkey = ? AND rev <= ? RETURNING subject AS "subject: OwnedDid""#, 126 + r#"DELETE FROM knot_member WHERE rkey = ? AND rev <= ? RETURNING subject AS "subject: DidBuf""#, 127 127 rkey, 128 128 rev 129 129 ) ··· 183 183 &self, 184 184 did: &Did, 185 185 rkey: &str, 186 - ) -> Result<(OwnedDid, String, OwnedDid), DataStoreError> { 186 + ) -> Result<(DidBuf, String, DidBuf), DataStoreError> { 187 187 let result = sqlx::query!( 188 - r#"SELECT repo_did as "repo_did: OwnedDid", repo_rkey, subject as "subject: OwnedDid" FROM repository_collaborator WHERE did = ? AND rkey = ?"#, 188 + r#"SELECT repo_did as "repo_did: DidBuf", repo_rkey, subject as "subject: DidBuf" FROM repository_collaborator WHERE did = ? AND rkey = ?"#, 189 189 did, 190 190 rkey 191 191 ) ··· 200 200 did: &Did, 201 201 rkey: &str, 202 202 rev: &str, 203 - ) -> Result<Option<OwnedDid>, DataStoreError> { 203 + ) -> Result<Option<DidBuf>, DataStoreError> { 204 204 let result = sqlx::query!( 205 - r#"DELETE FROM repository_collaborator WHERE did = ? AND rkey = ? AND rev <= ? RETURNING subject AS "subject: OwnedDid""#, 205 + r#"DELETE FROM repository_collaborator WHERE did = ? AND rkey = ? AND rev <= ? RETURNING subject AS "subject: DidBuf""#, 206 206 did, 207 207 rkey, 208 208 rev ··· 271 271 rev: &str, 272 272 ) -> Result<Option<DeletedRecord>, DataStoreError> { 273 273 let record = sqlx::query!( 274 - r#"DELETE FROM public_key WHERE did = ? AND rkey = ? AND rev <= ? RETURNING did AS "did: OwnedDid", rkey, rev, cid"#, 274 + r#"DELETE FROM public_key WHERE did = ? AND rkey = ? AND rev <= ? RETURNING did AS "did: DidBuf", rkey, rev, cid"#, 275 275 did, 276 276 rkey, 277 277 rev ··· 354 354 subject: &Did, 355 355 ) -> Result<bool, DataStoreError> { 356 356 let member = sqlx::query!( 357 - r#"SELECT repo_did as "repo_did: OwnedDid", repo_rkey, subject as "subject: OwnedDid" FROM repository_collaborator WHERE repo_did = ? AND repo_rkey = ? AND subject = ?"#, 357 + r#"SELECT repo_did as "repo_did: DidBuf", repo_rkey, subject as "subject: DidBuf" FROM repository_collaborator WHERE repo_did = ? AND repo_rkey = ? AND subject = ?"#, 358 358 repo_did, 359 359 repo_rkey, 360 360 subject ··· 369 369 370 370 pub async fn is_knot_member(&self, did: &Did) -> Result<bool, DataStoreError> { 371 371 let member = sqlx::query!( 372 - r#"SELECT subject as "subject: OwnedDid" FROM knot_member WHERE subject = ? LIMIT 1"#, 372 + r#"SELECT subject as "subject: DidBuf" FROM knot_member WHERE subject = ? LIMIT 1"#, 373 373 did, 374 374 ) 375 375 .fetch_optional(&self.db) ··· 527 527 assert_eq!(rec.collection, "sh.tangled.repo"); 528 528 529 529 let record = sqlx::query!( 530 - r#"DELETE FROM repository WHERE did = ? AND rkey = ? AND rev <= ? RETURNING did AS "did: OwnedDid", rkey, rev, cid, name"#, 530 + r#"DELETE FROM repository WHERE did = ? AND rkey = ? AND rev <= ? RETURNING did AS "did: DidBuf", rkey, rev, cid, name"#, 531 531 rec.did, 532 532 rec.rkey, 533 533 rec.rev
+2 -2
crates/gordian-knot/src/services/database/types.rs
··· 1 1 use crate::lexicon::sh_tangled::PublicKey; 2 - use gordian_types::{Did, OwnedDid}; 2 + use gordian_types::{Did, DidBuf}; 3 3 use time::OffsetDateTime; 4 4 5 5 /// A flattened public key record. ··· 77 77 78 78 #[derive(Debug)] 79 79 pub struct DeletedRecord { 80 - pub did: OwnedDid, 80 + pub did: DidBuf, 81 81 pub rkey: String, 82 82 pub rev: String, 83 83 pub cid: String,
+6 -6
crates/gordian-knot/src/types/repository_key.rs
··· 1 1 use core::fmt; 2 2 3 - use gordian_types::OwnedDid; 3 + use gordian_types::DidBuf; 4 4 use serde::Deserialize; 5 5 6 6 use super::repository_path::{Error, validate}; ··· 9 9 #[serde(try_from = "UnvalidatedRepositoryKey")] 10 10 pub struct RepositoryKey { 11 11 /// Repository owner's Did. 12 - pub owner: OwnedDid, 12 + pub owner: DidBuf, 13 13 14 14 /// Repository record key. 15 15 pub rkey: String, 16 16 } 17 17 18 18 impl RepositoryKey { 19 - pub fn new(owner: impl Into<OwnedDid>, rkey: impl Into<String>) -> Result<Self, Error> { 20 - fn inner(owner: OwnedDid, rkey: String) -> Result<RepositoryKey, Error> { 19 + pub fn new(owner: impl Into<DidBuf>, rkey: impl Into<String>) -> Result<Self, Error> { 20 + fn inner(owner: DidBuf, rkey: String) -> Result<RepositoryKey, Error> { 21 21 validate(&owner)?; 22 22 validate(&rkey)?; 23 23 ··· 29 29 30 30 #[derive(Deserialize)] 31 31 struct UnvalidatedRepositoryKey { 32 - owner: OwnedDid, 32 + owner: DidBuf, 33 33 rkey: String, 34 34 } 35 35 ··· 64 64 fn from_str(s: &str) -> Result<Self, Self::Err> { 65 65 let (owner, name) = s.split_once('/').ok_or(Error::Format)?; 66 66 67 - let owner: OwnedDid = owner.parse().map_err(|_| Error::Format)?; 67 + let owner: DidBuf = owner.parse().map_err(|_| Error::Format)?; 68 68 validate(owner.as_str())?; 69 69 validate(name)?; 70 70
+3 -3
crates/gordian-lexicon/src/sh_tangled/git.rs
··· 1 - use gordian_types::OwnedDid; 1 + use gordian_types::DidBuf; 2 2 use serde::{Deserialize, Serialize}; 3 3 4 4 use crate::extra::objectid::ObjectId; ··· 13 13 pub r#ref: String, 14 14 15 15 /// DID of the user that push this ref. 16 - pub committer_did: OwnedDid, 16 + pub committer_did: DidBuf, 17 17 18 18 /// DID of the owner of the repo. 19 - pub repo_did: OwnedDid, 19 + pub repo_did: DidBuf, 20 20 21 21 /// Name of the repo. 22 22 pub repo_name: String,
+3 -3
crates/gordian-lexicon/src/sh_tangled/repo.rs
··· 16 16 pub mod tags; 17 17 pub mod tree; 18 18 19 - use gordian_types::{Did, OwnedDid, RecordUri}; 19 + use gordian_types::{Did, DidBuf, RecordUri}; 20 20 use serde::{Deserialize, Serialize}; 21 21 use std::borrow::Cow; 22 22 use time::OffsetDateTime; ··· 57 57 pub body: Option<Cow<'a, str>>, 58 58 59 59 #[serde(skip_serializing_if = "Vec::is_empty")] 60 - pub mentions: Vec<OwnedDid>, 60 + pub mentions: Vec<DidBuf>, 61 61 62 62 #[serde(skip_serializing_if = "Vec::is_empty")] 63 63 pub references: Vec<RecordUri>, ··· 124 124 pub created_at: OffsetDateTime, 125 125 126 126 #[serde(skip_serializing_if = "Vec::is_empty")] 127 - pub mentions: Vec<OwnedDid>, 127 + pub mentions: Vec<DidBuf>, 128 128 129 129 #[serde(skip_serializing_if = "Vec::is_empty")] 130 130 pub references: Vec<RecordUri>,
+2 -2
crates/gordian-lexicon/src/sh_tangled/repo/delete.rs
··· 2 2 //! <https://tangled.org/@tangled.org/core/blob/master/lexicons/repo/delete.json> 3 3 //! 4 4 5 - use gordian_types::OwnedDid; 5 + use gordian_types::DidBuf; 6 6 use serde::{Deserialize, Serialize}; 7 7 8 8 /// Parameters for the `sh.tangled.repo.delete` procedure. ··· 12 12 #[serde(rename_all = "camelCase")] 13 13 pub struct Input { 14 14 /// DID of the repository owner. 15 - pub did: OwnedDid, 15 + pub did: DidBuf, 16 16 17 17 /// Record key of the repository record. 18 18 pub rkey: String,
+2 -2
crates/gordian-lexicon/src/sh_tangled/repo/issue.rs
··· 1 1 //! 2 2 //! <https://tangled.org/@tangled.org/core/tree/master/lexicons/issue> 3 3 //! 4 - use gordian_types::{OwnedDid, RecordUri}; 4 + use gordian_types::{DidBuf, RecordUri}; 5 5 use serde::{Deserialize, Serialize}; 6 6 use std::borrow::Cow; 7 7 use time::OffsetDateTime; ··· 24 24 pub reply_to: Option<RecordUri>, 25 25 26 26 #[serde(skip_serializing_if = "Vec::is_empty")] 27 - pub mentions: Vec<OwnedDid>, 27 + pub mentions: Vec<DidBuf>, 28 28 29 29 #[serde(skip_serializing_if = "Vec::is_empty")] 30 30 pub references: Vec<RecordUri>,
+2 -2
crates/gordian-lexicon/src/sh_tangled/repo/merge_check.rs
··· 3 3 //! 4 4 use std::borrow::Cow; 5 5 6 - use gordian_types::OwnedDid; 6 + use gordian_types::DidBuf; 7 7 use serde::{Deserialize, Serialize}; 8 8 9 9 /// Parameters for the `sh.tangled.repo.mergeCheck` query. ··· 12 12 #[derive(Debug, Deserialize)] 13 13 pub struct Input { 14 14 /// DID of the repository owner 15 - pub did: OwnedDid, 15 + pub did: DidBuf, 16 16 17 17 /// Name of the repository 18 18 pub name: String,
+1 -1
crates/gordian-lexicon/src/sh_tangled/repo/pull.rs
··· 20 20 pub created_at: time::OffsetDateTime, 21 21 22 22 #[serde(skip_serializing_if = "Vec::is_empty")] 23 - pub mentions: Vec<gordian_types::OwnedDid>, 23 + pub mentions: Vec<gordian_types::DidBuf>, 24 24 25 25 #[serde(skip_serializing_if = "Vec::is_empty")] 26 26 pub references: Vec<gordian_types::RecordUri>,
+3 -3
crates/gordian-pds/src/api.rs
··· 15 15 http::StatusCode, 16 16 response::IntoResponse, 17 17 }; 18 - use gordian_types::OwnedDid; 18 + use gordian_types::DidBuf; 19 19 use serde_json::Value; 20 20 use sqlx::Row as _; 21 21 ··· 36 36 37 37 #[derive(serde::Deserialize)] 38 38 pub struct Params { 39 - repo: OwnedDid, 39 + repo: DidBuf, 40 40 collection: String, 41 41 rkey: String, 42 42 cid: Option<String>, ··· 88 88 89 89 #[derive(serde::Deserialize)] 90 90 struct Params { 91 - repo: OwnedDid, 91 + repo: DidBuf, 92 92 collection: String, 93 93 } 94 94
+2 -2
crates/gordian-pds/src/state.rs
··· 8 8 use futures_util::FutureExt as _; 9 9 use gordian_auth::jwt; 10 10 use gordian_identity::DidDocument; 11 - use gordian_types::{OwnedDid, Tid}; 11 + use gordian_types::{DidBuf, Tid}; 12 12 use sqlx::{ 13 13 SqlitePool, 14 14 sqlite::{SqliteConnectOptions, SqlitePoolOptions}, ··· 173 173 fn resolve_handle<'s: 'h, 'h>( 174 174 &'s self, 175 175 handle: &'h str, 176 - ) -> futures_util::future::BoxFuture<'h, Result<OwnedDid, gordian_identity::ResolveError>> { 176 + ) -> futures_util::future::BoxFuture<'h, Result<DidBuf, gordian_identity::ResolveError>> { 177 177 use sqlx::Row as _; 178 178 async move { 179 179 let result = sqlx::query("SELECT did FROM identity WHERE handle = ?")
+32 -32
crates/gordian-types/src/did.rs
··· 185 185 186 186 /// An owned [`Did`] buffer with small-string optimization. 187 187 #[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] 188 - pub struct OwnedDid { 188 + pub struct DidBuf { 189 189 inner: SmallDid, 190 190 } 191 191 192 - impl OwnedDid { 192 + impl DidBuf { 193 193 fn new(did: impl Into<SmallDid>) -> Self { 194 194 let inner = did.into(); 195 195 Self { inner } ··· 231 231 } 232 232 } 233 233 234 - impl fmt::Debug for OwnedDid { 234 + impl fmt::Debug for DidBuf { 235 235 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 236 236 fmt::Debug::fmt(&self.inner, f) 237 237 } 238 238 } 239 239 240 - impl fmt::Display for OwnedDid { 240 + impl fmt::Display for DidBuf { 241 241 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 242 242 fmt::Display::fmt(&self.inner, f) 243 243 } 244 244 } 245 245 246 - impl AsRef<Did> for OwnedDid { 246 + impl AsRef<Did> for DidBuf { 247 247 #[inline] 248 248 fn as_ref(&self) -> &Did { 249 249 Did::new(&self.inner) 250 250 } 251 251 } 252 252 253 - impl borrow::Borrow<Did> for OwnedDid { 253 + impl borrow::Borrow<Did> for DidBuf { 254 254 fn borrow(&self) -> &Did { 255 255 Did::new(&self.inner) 256 256 } 257 257 } 258 258 259 259 impl ToOwned for Did { 260 - type Owned = OwnedDid; 260 + type Owned = DidBuf; 261 261 #[inline] 262 262 fn to_owned(&self) -> Self::Owned { 263 - OwnedDid::new(self.as_str()) 263 + DidBuf::new(self.as_str()) 264 264 } 265 265 } 266 266 267 - impl ops::Deref for OwnedDid { 267 + impl ops::Deref for DidBuf { 268 268 type Target = Did; 269 269 fn deref(&self) -> &Self::Target { 270 270 self.as_ref() 271 271 } 272 272 } 273 273 274 - impl From<&Did> for OwnedDid { 274 + impl From<&Did> for DidBuf { 275 275 fn from(value: &Did) -> Self { 276 276 value.to_owned() 277 277 } ··· 279 279 280 280 macro_rules! impl_owned_tryfrom { 281 281 ($t:ty) => { 282 - impl TryFrom<$t> for OwnedDid { 282 + impl TryFrom<$t> for DidBuf { 283 283 type Error = Error; 284 284 fn try_from(value: $t) -> Result<Self, Self::Error> { 285 285 validate_did(&value)?; ··· 293 293 impl_owned_tryfrom!(String); 294 294 impl_owned_tryfrom!(Box<str>); 295 295 296 - impl std::str::FromStr for OwnedDid { 296 + impl std::str::FromStr for DidBuf { 297 297 type Err = Error; 298 298 fn from_str(s: &str) -> Result<Self, Self::Err> { 299 299 s.try_into() 300 300 } 301 301 } 302 302 303 - impl From<OwnedDid> for std::borrow::Cow<'_, Did> { 303 + impl From<DidBuf> for std::borrow::Cow<'_, Did> { 304 304 #[inline] 305 - fn from(value: OwnedDid) -> Self { 305 + fn from(value: DidBuf) -> Self { 306 306 std::borrow::Cow::Owned(value) 307 307 } 308 308 } ··· 314 314 } 315 315 } 316 316 317 - impl From<std::borrow::Cow<'_, Did>> for OwnedDid { 317 + impl From<std::borrow::Cow<'_, Did>> for DidBuf { 318 318 fn from(value: std::borrow::Cow<'_, Did>) -> Self { 319 319 use std::borrow::Cow; 320 320 match value { ··· 324 324 } 325 325 } 326 326 327 - impl_partial_eq!(OwnedDid, &Did); 328 - impl_partial_eq!(OwnedDid, &str); 327 + impl_partial_eq!(DidBuf, &Did); 328 + impl_partial_eq!(DidBuf, &str); 329 329 330 330 #[cfg(feature = "serde")] 331 - impl_str_wrapper_serde!(Did, OwnedDid); 331 + impl_str_wrapper_serde!(Did, DidBuf); 332 332 333 333 #[cfg(feature = "sqlx")] 334 334 mod sqlx_impl { 335 - use super::{Did, OwnedDid}; 335 + use super::{Did, DidBuf}; 336 336 impl_str_wrapper_sqlx!(ref Did); 337 337 impl_str_wrapper_sqlx!(Box<Did>); 338 - impl_str_wrapper_sqlx!(OwnedDid); 338 + impl_str_wrapper_sqlx!(DidBuf); 339 339 } 340 340 341 341 #[cfg(test)] 342 342 mod tests { 343 - use super::{Did, Error, OwnedDid}; 343 + use super::{Did, DidBuf, Error}; 344 344 345 345 /// An example DID. 346 346 const EXAMPLE_DID: &str = "did:plc:65gha4t3avpfpzmvpbwovss7"; ··· 414 414 #[should_panic] 415 415 fn reject_invalid_static() { 416 416 let _ = Did::from_static("did:_plc:asdf"); 417 - let _ = OwnedDid::from_static("did:plc65gha4t3avpfpzmvpbwovss7"); 417 + let _ = DidBuf::from_static("did:plc65gha4t3avpfpzmvpbwovss7"); 418 418 } 419 419 420 420 #[test] ··· 424 424 assert_eq!(format!("{did}"), EXAMPLE_DID); 425 425 assert_eq!(format!("{did:?}"), format!("{EXAMPLE_DID:?}")); 426 426 427 - let owned: OwnedDid = did.into(); 427 + let owned: DidBuf = did.into(); 428 428 assert_eq!(format!("{owned}"), EXAMPLE_DID); 429 429 assert_eq!(format!("{owned:?}"), format!("{EXAMPLE_DID:?}")); 430 430 } ··· 436 436 437 437 #[test] 438 438 fn can_parse_to_owned() { 439 - let _: OwnedDid = EXAMPLE_DID.parse().unwrap(); 439 + let _: DidBuf = EXAMPLE_DID.parse().unwrap(); 440 440 } 441 441 442 442 #[test] 443 443 fn can_convert_static() { 444 444 let _: &'static str = EXAMPLE_DID.try_into().unwrap(); 445 - let _: OwnedDid = EXAMPLE_DID.try_into().unwrap(); 446 - let _ = OwnedDid::from_static(EXAMPLE_DID); 445 + let _: DidBuf = EXAMPLE_DID.try_into().unwrap(); 446 + let _ = DidBuf::from_static(EXAMPLE_DID); 447 447 } 448 448 449 449 #[test] ··· 499 499 fn can_serde_owned() { 500 500 #[derive(serde::Deserialize, serde::Serialize)] 501 501 struct Test { 502 - did: OwnedDid, 502 + did: DidBuf, 503 503 } 504 504 505 505 let test = Test { 506 - did: OwnedDid::from_static(EXAMPLE_DID), 506 + did: DidBuf::from_static(EXAMPLE_DID), 507 507 }; 508 508 509 509 let json = serde_json::to_string(&test).unwrap(); ··· 603 603 did: Cow<'a, Did>, 604 604 } 605 605 606 - let did = OwnedDid::parse(EXAMPLE_DID).unwrap(); 606 + let did = DidBuf::parse(EXAMPLE_DID).unwrap(); 607 607 let test = Test { 608 608 did: Cow::Owned(did), 609 609 }; ··· 620 620 fn can_convert_cow() { 621 621 use std::borrow::Cow; 622 622 623 - let did = OwnedDid::from_static(EXAMPLE_DID); 623 + let did = DidBuf::from_static(EXAMPLE_DID); 624 624 let cow: Cow<_> = did.into(); 625 625 assert!(matches!(cow, Cow::Owned(_))); 626 626 627 627 // Convert back to owned. 628 - let _: OwnedDid = cow.into(); 628 + let _: DidBuf = cow.into(); 629 629 630 630 let did = Did::from_static(EXAMPLE_DID); 631 631 let cow: Cow<_> = did.into(); ··· 634 634 635 635 #[test] 636 636 fn owned_plc_doesnt_allocate() { 637 - let did = OwnedDid::parse("did:plc:65gha4t3avpfpzmvpbwovss7").unwrap(); 637 + let did = DidBuf::parse("did:plc:65gha4t3avpfpzmvpbwovss7").unwrap(); 638 638 assert!(!did.inner.spilled(), "DID PLC should not spill onto heap"); 639 639 } 640 640 }
+1 -1
crates/gordian-types/src/lib.rs
··· 11 11 pub mod tid; 12 12 pub mod uri; 13 13 14 - pub use did::{Did, OwnedDid}; 14 + pub use did::{Did, DidBuf}; 15 15 pub use handle::Handle; 16 16 pub use nsid::Nsid; 17 17 pub use tid::{Tid, TidClock};
+4 -4
crates/gordian-types/src/uri.rs
··· 1 - use crate::{Did, did::OwnedDid}; 1 + use crate::{Did, did::DidBuf}; 2 2 3 3 /// A fully defined Atmosphere URI pointing to a record. 4 4 /// ··· 6 6 /// 7 7 #[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] 8 8 pub struct RecordUri { 9 - pub authority: OwnedDid, 9 + pub authority: DidBuf, 10 10 pub collection: String, 11 11 pub rkey: String, 12 12 } 13 13 14 14 impl RecordUri { 15 15 pub fn new( 16 - authority: impl Into<OwnedDid>, 16 + authority: impl Into<DidBuf>, 17 17 collection: impl Into<String>, 18 18 rkey: impl Into<String>, 19 19 ) -> Self { ··· 60 60 let mut parts = uri.splitn(3, '/'); 61 61 let authority = parts 62 62 .next() 63 - .map(OwnedDid::parse) 63 + .map(DidBuf::parse) 64 64 .transpose()? 65 65 .ok_or(Error::Error)?; 66 66 let collection = parts.next().ok_or(Error::Error)?.to_string();