From a0fbf9d2367c6fff9f3d91ccece94be264436467 Mon Sep 17 00:00:00 2001 From: asonix Date: Tue, 6 Dec 2022 18:53:19 -0600 Subject: [PATCH] Bump activitystreams again --- Cargo.lock | 13 ++++++------ src/config.rs | 57 +++++++++++++++++++++++++++++++++------------------ src/error.rs | 5 +---- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0224515..457d221 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "activitystreams" -version = "0.7.0-alpha.21" +version = "0.7.0-alpha.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b81ea88d9e6c12a023479a2638f2f50853ec7e6fbaba1e9f94d6224814e634" +checksum = "713061473d42baa5527b1dbf07b86a506c48df3190a4fb840fb7fcea8cf1b724" dependencies = [ "activitystreams-kinds", "iri-string", @@ -29,9 +29,9 @@ dependencies = [ [[package]] name = "activitystreams-kinds" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d014a4fb8828870b7b46bee6257b9a89d06188ae8d435381ba94f14c8c697d8" +checksum = "e97dfe76efd8c0b113cc3580a6b5f4acba47662e3cfbbfcce081c9ac89798990" dependencies = [ "iri-string", "serde", @@ -1491,10 +1491,11 @@ checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" [[package]] name = "iri-string" -version = "0.5.6" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf071934ee7ee97e52fa1868a9540a7885eab75926bd70794030304a9797cea1" +checksum = "21859b667d66a4c1dacd9df0863b3efb65785474255face87f5bca39dd8407c0" dependencies = [ + "memchr", "serde", ] diff --git a/src/config.rs b/src/config.rs index 1d4cf86..61aa7a9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,6 +8,7 @@ use crate::{ use activitystreams::{ iri, iri_string::{ + format::ToDedicatedString, resolve::FixedBaseResolver, types::{IriAbsoluteString, IriFragmentStr, IriRelativeStr, IriString}, }, @@ -398,34 +399,42 @@ impl Config { #[tracing::instrument(level = "debug", skip_all, fields(base_uri = tracing::field::debug(&self.base_uri), kind = tracing::field::debug(&kind)))] fn do_generate_url(&self, kind: UrlKind) -> Result { let iri = match kind { - UrlKind::Activity => FixedBaseResolver::new(self.base_uri.as_ref()).try_resolve( - IriRelativeStr::new(&format!("activity/{}", Uuid::new_v4()))?.as_ref(), - )?, + UrlKind::Activity => FixedBaseResolver::new(self.base_uri.as_ref()) + .resolve(IriRelativeStr::new(&format!("activity/{}", Uuid::new_v4()))?.as_ref()) + .try_to_dedicated_string()?, UrlKind::Actor => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("actor")?.as_ref())?, + .resolve(IriRelativeStr::new("actor")?.as_ref()) + .try_to_dedicated_string()?, UrlKind::Followers => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("followers")?.as_ref())?, + .resolve(IriRelativeStr::new("followers")?.as_ref()) + .try_to_dedicated_string()?, UrlKind::Following => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("following")?.as_ref())?, + .resolve(IriRelativeStr::new("following")?.as_ref()) + .try_to_dedicated_string()?, UrlKind::Inbox => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("inbox")?.as_ref())?, + .resolve(IriRelativeStr::new("inbox")?.as_ref()) + .try_to_dedicated_string()?, UrlKind::Index => self.base_uri.clone().into(), UrlKind::MainKey => { let actor = IriRelativeStr::new("actor")?; let fragment = IriFragmentStr::new("main-key")?; - let mut resolved = - FixedBaseResolver::new(self.base_uri.as_ref()).try_resolve(actor.as_ref())?; + let mut resolved = FixedBaseResolver::new(self.base_uri.as_ref()) + .resolve(actor.as_ref()) + .try_to_dedicated_string()?; resolved.set_fragment(Some(fragment)); resolved } UrlKind::Media(uuid) => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new(&format!("media/{}", uuid))?.as_ref())?, + .resolve(IriRelativeStr::new(&format!("media/{}", uuid))?.as_ref()) + .try_to_dedicated_string()?, UrlKind::NodeInfo => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("nodeinfo/2.0.json")?.as_ref())?, + .resolve(IriRelativeStr::new("nodeinfo/2.0.json")?.as_ref()) + .try_to_dedicated_string()?, UrlKind::Outbox => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("outbox")?.as_ref())?, + .resolve(IriRelativeStr::new("outbox")?.as_ref()) + .try_to_dedicated_string()?, }; Ok(iri) @@ -439,21 +448,29 @@ impl Config { fn do_generate_admin_url(&self, kind: AdminUrlKind) -> Result { let iri = match kind { AdminUrlKind::Allow => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("api/v1/admin/allow")?.as_ref())?, + .resolve(IriRelativeStr::new("api/v1/admin/allow")?.as_ref()) + .try_to_dedicated_string()?, AdminUrlKind::Disallow => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("api/v1/admin/disallow")?.as_ref())?, + .resolve(IriRelativeStr::new("api/v1/admin/disallow")?.as_ref()) + .try_to_dedicated_string()?, AdminUrlKind::Block => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("api/v1/admin/block")?.as_ref())?, + .resolve(IriRelativeStr::new("api/v1/admin/block")?.as_ref()) + .try_to_dedicated_string()?, AdminUrlKind::Unblock => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("api/v1/admin/unblock")?.as_ref())?, + .resolve(IriRelativeStr::new("api/v1/admin/unblock")?.as_ref()) + .try_to_dedicated_string()?, AdminUrlKind::Allowed => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("api/v1/admin/allowed")?.as_ref())?, + .resolve(IriRelativeStr::new("api/v1/admin/allowed")?.as_ref()) + .try_to_dedicated_string()?, AdminUrlKind::Blocked => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("api/v1/admin/blocked")?.as_ref())?, + .resolve(IriRelativeStr::new("api/v1/admin/blocked")?.as_ref()) + .try_to_dedicated_string()?, AdminUrlKind::Connected => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("api/v1/admin/connected")?.as_ref())?, + .resolve(IriRelativeStr::new("api/v1/admin/connected")?.as_ref()) + .try_to_dedicated_string()?, AdminUrlKind::Stats => FixedBaseResolver::new(self.base_uri.as_ref()) - .try_resolve(IriRelativeStr::new("api/v1/admin/stats")?.as_ref())?, + .resolve(IriRelativeStr::new("api/v1/admin/stats")?.as_ref()) + .try_to_dedicated_string()?, }; Ok(iri) diff --git a/src/error.rs b/src/error.rs index 8fcd05d..f399ebe 100644 --- a/src/error.rs +++ b/src/error.rs @@ -77,10 +77,7 @@ pub(crate) enum ErrorKind { ParseIri(#[from] activitystreams::iri_string::validate::Error), #[error("Couldn't normalize IRI, {0}")] - NormalizeIri( - #[from] - activitystreams::iri_string::task::Error, - ), + NormalizeIri(#[from] std::collections::TryReserveError), #[error("Couldn't perform IO, {0}")] Io(#[from] io::Error),