From 8c191cf9ae12b1cb7c9863ce592eea3c70ff6dba Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 28 Dec 2024 02:39:25 +0100 Subject: [PATCH] `astreams`: Rename functions --- acrate_astreams/src/activitystreams/jsonld.rs | 30 +++++++++---------- acrate_astreams/src/activitystreams/mod.rs | 6 ++-- acrate_astreams/tests/test_activitystreams.rs | 6 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/acrate_astreams/src/activitystreams/jsonld.rs b/acrate_astreams/src/activitystreams/jsonld.rs index a4e2aef..e1970cc 100644 --- a/acrate_astreams/src/activitystreams/jsonld.rs +++ b/acrate_astreams/src/activitystreams/jsonld.rs @@ -7,14 +7,14 @@ use mediatype::MediaType; use crate::activitystreams::StreamsLink; pub trait StreamsJsonLD { - fn get_one_str(&self, id: &Iri) -> Option>; - fn get_multiple_str(&self, id: &Iri) -> impl Iterator>; - fn get_one_mediatype(&self, id: &Iri) -> Option>; - fn get_node_str(&self, id: &Iri) -> Option>; + fn jsonld_any_value_string(&self, id: &Iri) -> Option>; + fn jsonld_iter_value_string(&self, id: &Iri) -> impl Iterator>; + fn jsonld_any_value_mediatype(&self, id: &Iri) -> Option>; + fn jsonld_any_node_string(&self, id: &Iri) -> Option>; } impl StreamsJsonLD for &json_ld::Node { - fn get_one_str(&self, id: &Iri) -> Option> { + fn jsonld_any_value_string(&self, id: &Iri) -> Option> { let property = match self.properties.get_any(&id) { None => return None, Some(property) => property, @@ -35,7 +35,7 @@ impl StreamsJsonLD for &json_ld::Node { Some(Ok(string)) } - fn get_multiple_str(&self, id: &Iri) -> impl Iterator> { + fn jsonld_iter_value_string(&self, id: &Iri) -> impl Iterator> { let properties = self.properties.get(&id); let values = properties.map(|v| v @@ -59,7 +59,7 @@ impl StreamsJsonLD for &json_ld::Node { strings } - fn get_one_mediatype(&self, id: &Iri) -> Option> { + fn jsonld_any_value_mediatype(&self, id: &Iri) -> Option> { let property = match self.properties.get_any(&id) { None => return None, Some(property) => property, @@ -83,7 +83,7 @@ impl StreamsJsonLD for &json_ld::Node { Some(Ok(mediatype)) } - fn get_node_str(&self, id: &Iri) -> Option> { + fn jsonld_any_node_string(&self, id: &Iri) -> Option> { let property = match self.properties.get_any(&id) { None => return None, Some(property) => property, @@ -106,26 +106,26 @@ impl StreamsJsonLD for &json_ld::Node { } impl StreamsLink for &json_ld::Node { - fn streams_href(&self) -> Option> { - self.get_node_str( + fn activitystreams_href(&self) -> Option> { + self.jsonld_any_node_string( iri!("https://www.w3.org/ns/activitystreams#href") ) } - fn streams_rel(&self) -> impl Iterator> { - self.get_multiple_str( + fn activitystreams_rel(&self) -> impl Iterator> { + self.jsonld_iter_value_string( iri!("https://www.w3.org/ns/activitystreams#rel") ) } - fn streams_media_type(&self) -> Option> { - self.get_one_mediatype( + fn activitystreams_mediatype(&self) -> Option> { + self.jsonld_any_value_mediatype( iri!("https://www.w3.org/ns/activitystreams#mediaType") ) } /* - fn streams_name(&self) -> impl Iterator, String)>> { + fn activitystreams_name(&self) -> impl Iterator, String)>> { todo!() } */ diff --git a/acrate_astreams/src/activitystreams/mod.rs b/acrate_astreams/src/activitystreams/mod.rs index e5da225..dbac944 100644 --- a/acrate_astreams/src/activitystreams/mod.rs +++ b/acrate_astreams/src/activitystreams/mod.rs @@ -23,12 +23,12 @@ pub trait StreamsObject { /// Something that can be considered a `https://www.w3.org/ns/activitystreams#Link`. pub trait StreamsLink { - fn streams_href(&self) -> Option>; + fn activitystreams_href(&self) -> Option>; // FIXME: This accepts any kind of string, and does not filter to HTML link relations - fn streams_rel(&self) -> impl Iterator>; + fn activitystreams_rel(&self) -> impl Iterator>; - fn streams_media_type(&self) -> Option>; + fn activitystreams_mediatype(&self) -> Option>; /* fn streams_name(&self) -> impl Iterator>; diff --git a/acrate_astreams/tests/test_activitystreams.rs b/acrate_astreams/tests/test_activitystreams.rs index b290b01..d6a5ecc 100644 --- a/acrate_astreams/tests/test_activitystreams.rs +++ b/acrate_astreams/tests/test_activitystreams.rs @@ -215,7 +215,7 @@ async fn test_link_href() { let href = { use acrate_astreams::activitystreams::StreamsLink; - node.streams_href() + node.activitystreams_href() .expect("Property `href` was not found") .expect("Property `href` failed to process") }; @@ -233,7 +233,7 @@ async fn test_link_rel() { let mut rels = { use acrate_astreams::activitystreams::StreamsLink; - node.streams_rel() + node.activitystreams_rel() .map(|v| v .expect("Property `rel` failed to process") ) @@ -260,7 +260,7 @@ async fn test_link_media_type() { let href = { use acrate_astreams::activitystreams::StreamsLink; - node.streams_media_type() + node.activitystreams_mediatype() .expect("Property `mediaType` was not found") .expect("Property `mediaType` failed to process") };