astreams: Rename functions

This commit is contained in:
Steffo 2024-12-28 02:39:25 +01:00
parent ea126d11f4
commit 8c191cf9ae
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
3 changed files with 21 additions and 21 deletions

View file

@ -7,14 +7,14 @@ use mediatype::MediaType;
use crate::activitystreams::StreamsLink;
pub trait StreamsJsonLD {
fn get_one_str(&self, id: &Iri) -> Option<AResult<String>>;
fn get_multiple_str(&self, id: &Iri) -> impl Iterator<Item = AResult<String>>;
fn get_one_mediatype(&self, id: &Iri) -> Option<AResult<MediaType>>;
fn get_node_str(&self, id: &Iri) -> Option<AResult<String>>;
fn jsonld_any_value_string(&self, id: &Iri) -> Option<AResult<String>>;
fn jsonld_iter_value_string(&self, id: &Iri) -> impl Iterator<Item = AResult<String>>;
fn jsonld_any_value_mediatype(&self, id: &Iri) -> Option<AResult<MediaType>>;
fn jsonld_any_node_string(&self, id: &Iri) -> Option<AResult<String>>;
}
impl StreamsJsonLD for &json_ld::Node {
fn get_one_str(&self, id: &Iri) -> Option<AResult<String>> {
fn jsonld_any_value_string(&self, id: &Iri) -> Option<AResult<String>> {
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<Item = AResult<String>> {
fn jsonld_iter_value_string(&self, id: &Iri) -> impl Iterator<Item = AResult<String>> {
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<AResult<MediaType>> {
fn jsonld_any_value_mediatype(&self, id: &Iri) -> Option<AResult<MediaType>> {
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<AResult<String>> {
fn jsonld_any_node_string(&self, id: &Iri) -> Option<AResult<String>> {
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<AResult<String>> {
self.get_node_str(
fn activitystreams_href(&self) -> Option<AResult<String>> {
self.jsonld_any_node_string(
iri!("https://www.w3.org/ns/activitystreams#href")
)
}
fn streams_rel(&self) -> impl Iterator<Item = AResult<String>> {
self.get_multiple_str(
fn activitystreams_rel(&self) -> impl Iterator<Item = AResult<String>> {
self.jsonld_iter_value_string(
iri!("https://www.w3.org/ns/activitystreams#rel")
)
}
fn streams_media_type(&self) -> Option<AResult<MediaType>> {
self.get_one_mediatype(
fn activitystreams_mediatype(&self) -> Option<AResult<MediaType>> {
self.jsonld_any_value_mediatype(
iri!("https://www.w3.org/ns/activitystreams#mediaType")
)
}
/*
fn streams_name(&self) -> impl Iterator<Item=AResult<(Option<LanguageTag>, String)>> {
fn activitystreams_name(&self) -> impl Iterator<Item=AResult<(Option<LanguageTag>, String)>> {
todo!()
}
*/

View file

@ -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<AResult<String>>;
fn activitystreams_href(&self) -> Option<AResult<String>>;
// FIXME: This accepts any kind of string, and does not filter to HTML link relations
fn streams_rel(&self) -> impl Iterator<Item = AResult<String>>;
fn activitystreams_rel(&self) -> impl Iterator<Item = AResult<String>>;
fn streams_media_type(&self) -> Option<AResult<MediaType>>;
fn activitystreams_mediatype(&self) -> Option<AResult<MediaType>>;
/*
fn streams_name(&self) -> impl Iterator<Item = AResult<(LanguageTag, String)>>;

View file

@ -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")
};