diff --git a/apb/src/field.rs b/apb/src/field.rs index 336148e..46a6f50 100644 --- a/apb/src/field.rs +++ b/apb/src/field.rs @@ -3,16 +3,3 @@ pub struct FieldErr(pub &'static str); pub type Field = Result; - - -// TODO this trait is really ad-hoc and has awful naming... - -pub trait OptionalString { - fn str(self) -> Option; -} - -impl OptionalString for Field<&str> { - fn str(self) -> Option { - self.ok().map(|x| x.to_string()) - } -} diff --git a/apb/src/key.rs b/apb/src/key.rs index fe41f8b..6ad9ae8 100644 --- a/apb/src/key.rs +++ b/apb/src/key.rs @@ -1,32 +1,32 @@ // TODO technically this is not part of ActivityStreams pub trait PublicKey : super::Base { - fn owner(&self) -> crate::Field<&str> { Err(crate::FieldErr("owner")) } - fn public_key_pem(&self) -> &str; + fn owner(&self) -> crate::Field { Err(crate::FieldErr("owner")) } + fn public_key_pem(&self) -> String; } pub trait PublicKeyMut : super::BaseMut { - fn set_owner(self, val: Option<&str>) -> Self; - fn set_public_key_pem(self, val: &str) -> Self; + fn set_owner(self, val: Option) -> Self; + fn set_public_key_pem(self, val: String) -> Self; } #[cfg(feature = "unstructured")] impl PublicKey for serde_json::Value { - crate::getter! { owner -> &str } + crate::getter! { owner -> String } - fn public_key_pem(&self) -> &str { - self.get("publicKeyPem").map(|x| x.as_str().unwrap_or_default()).unwrap_or_default() + fn public_key_pem(&self) -> String { + self.get("publicKeyPem").and_then(|x| x.as_str()).unwrap_or_default().to_string() } } #[cfg(feature = "unstructured")] impl PublicKeyMut for serde_json::Value { - crate::setter! { owner -> &str } + crate::setter! { owner -> String } - fn set_public_key_pem(mut self, val: &str) -> Self { + fn set_public_key_pem(mut self, val: String) -> Self { self.as_object_mut().unwrap().insert( "publicKeyPem".to_string(), - serde_json::Value::String(val.to_string()), + serde_json::Value::String(val), ); self } diff --git a/apb/src/macros.rs b/apb/src/macros.rs index 0d8fced..fbb9702 100644 --- a/apb/src/macros.rs +++ b/apb/src/macros.rs @@ -137,11 +137,12 @@ macro_rules! getter { } }; - ($name:ident -> &str) => { + ($name:ident -> String) => { paste::paste! { - fn [< $name:snake >](&self) -> $crate::Field<&str> { + fn [< $name:snake >](&self) -> $crate::Field { self.get(stringify!($name)) .and_then(|x| x.as_str()) + .map(|x| x.to_string()) .ok_or($crate::FieldErr(stringify!($name))) } } @@ -225,11 +226,11 @@ macro_rules! setter { } }; - ($name:ident -> &str) => { + ($name:ident -> String) => { paste::item! { - fn [< set_$name:snake >](mut self, val: Option<&str>) -> Self { + fn [< set_$name:snake >](mut self, val: Option) -> Self { $crate::macros::set_maybe_value( - &mut self, stringify!($name), val.map(|x| serde_json::Value::String(x.to_string())) + &mut self, stringify!($name), val.map(|x| serde_json::Value::String(x)) ); self } diff --git a/apb/src/node.rs b/apb/src/node.rs index c0716df..9d23bfb 100644 --- a/apb/src/node.rs +++ b/apb/src/node.rs @@ -113,7 +113,7 @@ impl Node { } /// returns id of object: url for link, id for object, None if empty or array - pub fn id(&self) -> crate::Field<&str> { + pub fn id(&self) -> crate::Field { match self { Node::Empty => Err(crate::FieldErr("id")), Node::Link(uri) => uri.href(), diff --git a/apb/src/types/base.rs b/apb/src/types/base.rs index 44b271e..d3955d6 100644 --- a/apb/src/types/base.rs +++ b/apb/src/types/base.rs @@ -9,20 +9,20 @@ crate::strenum! { } pub trait Base : crate::macros::MaybeSend { - fn id(&self) -> crate::Field<&str> { Err(crate::FieldErr("id")) } + fn id(&self) -> crate::Field { Err(crate::FieldErr("id")) } fn base_type(&self) -> crate::Field { Err(crate::FieldErr("type")) } } pub trait BaseMut : crate::macros::MaybeSend { - fn set_id(self, val: Option<&str>) -> Self; + fn set_id(self, val: Option) -> Self; fn set_base_type(self, val: Option) -> Self; } impl Base for String { - fn id(&self) -> crate::Field<&str> { - Ok(self) + fn id(&self) -> crate::Field { + Ok(self.clone()) } fn base_type(&self) -> crate::Field { @@ -43,12 +43,13 @@ impl Base for serde_json::Value { } } - fn id(&self) -> crate::Field<&str> { + fn id(&self) -> crate::Field { if self.is_string() { - Ok(self.as_str().ok_or(crate::FieldErr("id"))?) + Ok(self.as_str().ok_or(crate::FieldErr("id"))?.to_string()) } else { self.get("id") .and_then(|x| x.as_str()) + .map(|x| x.to_string()) .ok_or(crate::FieldErr("id")) } } @@ -56,6 +57,6 @@ impl Base for serde_json::Value { #[cfg(feature = "unstructured")] impl BaseMut for serde_json::Value { - crate::setter! { id -> &str } + crate::setter! { id -> String } crate::setter! { base_type -> type BaseType } } diff --git a/apb/src/types/link.rs b/apb/src/types/link.rs index e21f0af..8de477e 100644 --- a/apb/src/types/link.rs +++ b/apb/src/types/link.rs @@ -19,79 +19,82 @@ crate::strenum! { pub trait Link : crate::Base { fn link_type(&self) -> Field { Err(FieldErr("type")) } - fn href(&self) -> Field<&str>; - fn rel(&self) -> Field<&str> { Err(FieldErr("rel")) } - fn media_type(&self) -> Field<&str> { Err(FieldErr("mediaType")) } // also in obj - fn name(&self) -> Field<&str> { Err(FieldErr("name")) } // also in obj - fn hreflang(&self) -> Field<&str> { Err(FieldErr("hreflang")) } + fn href(&self) -> Field; + fn rel(&self) -> Field { Err(FieldErr("rel")) } + fn media_type(&self) -> Field { Err(FieldErr("mediaType")) } // also in obj + fn name(&self) -> Field { Err(FieldErr("name")) } // also in obj + fn hreflang(&self) -> Field { Err(FieldErr("hreflang")) } fn height(&self) -> Field { Err(FieldErr("height")) } fn width(&self) -> Field { Err(FieldErr("width")) } - fn preview(&self) -> Field<&str> { Err(FieldErr("linkPreview")) } // also in obj + fn preview(&self) -> Field { Err(FieldErr("linkPreview")) } // also in obj } pub trait LinkMut : crate::BaseMut { fn set_link_type(self, val: Option) -> Self; - fn set_href(self, href: Option<&str>) -> Self; - fn set_rel(self, val: Option<&str>) -> Self; - fn set_media_type(self, val: Option<&str>) -> Self; // also in obj - fn set_name(self, val: Option<&str>) -> Self; // also in obj - fn set_hreflang(self, val: Option<&str>) -> Self; + fn set_href(self, href: Option) -> Self; + fn set_rel(self, val: Option) -> Self; + fn set_media_type(self, val: Option) -> Self; // also in obj + fn set_name(self, val: Option) -> Self; // also in obj + fn set_hreflang(self, val: Option) -> Self; fn set_height(self, val: Option) -> Self; fn set_width(self, val: Option) -> Self; - fn set_preview(self, val: Option<&str>) -> Self; // also in obj + fn set_preview(self, val: Option) -> Self; // also in obj } impl Link for String { - fn href(&self) -> Field<&str> { - Ok(self) + fn href(&self) -> Field { + Ok(self.to_string()) } } #[cfg(feature = "unstructured")] impl Link for serde_json::Value { // TODO this can fail, but it should never do! - fn href(&self) -> Field<&str> { + fn href(&self) -> Field { if self.is_string() { - self.as_str().ok_or(FieldErr("href")) + self.as_str().map(|x| x.to_string()).ok_or(FieldErr("href")) } else { - self.get("href").and_then(|x| x.as_str()).ok_or(FieldErr("href")) + self.get("href") + .and_then(|x| x.as_str()) + .map(|x| x.to_string()) + .ok_or(FieldErr("href")) } } crate::getter! { link_type -> type LinkType } - crate::getter! { rel -> &str } - crate::getter! { mediaType -> &str } - crate::getter! { name -> &str } - crate::getter! { hreflang -> &str } + crate::getter! { rel -> String } + crate::getter! { mediaType -> String } + crate::getter! { name -> String } + crate::getter! { hreflang -> String } crate::getter! { height -> u64 } crate::getter! { width -> u64 } - crate::getter! { preview -> &str } + crate::getter! { preview -> String } } #[cfg(feature = "unstructured")] impl LinkMut for serde_json::Value { - fn set_href(mut self, href: Option<&str>) -> Self { + fn set_href(mut self, href: Option) -> Self { match &mut self { serde_json::Value::Object(map) => { match href { Some(href) => map.insert( "href".to_string(), - serde_json::Value::String(href.to_string()) + serde_json::Value::String(href) ), None => map.remove("href"), }; }, - x => *x = serde_json::Value::String(href.unwrap_or_default().to_string()), + x => *x = serde_json::Value::String(href.unwrap_or_default()), } self } crate::setter! { link_type -> type LinkType } - crate::setter! { rel -> &str } - crate::setter! { mediaType -> &str } - crate::setter! { name -> &str } - crate::setter! { hreflang -> &str } + crate::setter! { rel -> String } + crate::setter! { mediaType -> String } + crate::setter! { name -> String } + crate::setter! { hreflang -> String } crate::setter! { height -> u64 } crate::setter! { width -> u64 } - crate::setter! { preview -> &str } + crate::setter! { preview -> String } } diff --git a/apb/src/types/object/actor.rs b/apb/src/types/object/actor.rs index 8784429..896f6d9 100644 --- a/apb/src/types/object/actor.rs +++ b/apb/src/types/object/actor.rs @@ -16,7 +16,7 @@ pub trait Actor : Object { fn actor_type(&self) -> Field { Err(FieldErr("type")) } /// A short username which may be used to refer to the actor, with no uniqueness guarantees. - fn preferred_username(&self) -> Field<&str> { Err(FieldErr("preferredUsername")) } + fn preferred_username(&self) -> Field { Err(FieldErr("preferredUsername")) } /// A reference to an [ActivityStreams] OrderedCollection comprised of all the messages received by the actor; see 5.2 Inbox. fn inbox(&self) -> Node; /// An [ActivityStreams] OrderedCollection comprised of all the messages produced by the actor; see 5.1 Outbox. @@ -64,17 +64,17 @@ pub trait Actor : Object { pub trait Endpoints : Object { /// Endpoint URI so this actor's clients may access remote ActivityStreams objects which require authentication to access. To use this endpoint, the client posts an x-www-form-urlencoded id parameter with the value being the id of the requested ActivityStreams object. - fn proxy_url(&self) -> Field<&str> { Err(FieldErr("proxyUrl")) } + fn proxy_url(&self) -> Field { Err(FieldErr("proxyUrl")) } /// If OAuth 2.0 bearer tokens [RFC6749] [RFC6750] are being used for authenticating client to server interactions, this endpoint specifies a URI at which a browser-authenticated user may obtain a new authorization grant. - fn oauth_authorization_endpoint(&self) -> Field<&str> { Err(FieldErr("oauthAuthorizationEndpoint")) } + fn oauth_authorization_endpoint(&self) -> Field { Err(FieldErr("oauthAuthorizationEndpoint")) } /// If OAuth 2.0 bearer tokens [RFC6749] [RFC6750] are being used for authenticating client to server interactions, this endpoint specifies a URI at which a client may acquire an access token. - fn oauth_token_endpoint(&self) -> Field<&str> { Err(FieldErr("oauthTokenEndpoint")) } + fn oauth_token_endpoint(&self) -> Field { Err(FieldErr("oauthTokenEndpoint")) } /// If Linked Data Signatures and HTTP Signatures are being used for authentication and authorization, this endpoint specifies a URI at which browser-authenticated users may authorize a client's public key for client to server interactions. - fn provide_client_key(&self) -> Field<&str> { Err(FieldErr("provideClientKey")) } + fn provide_client_key(&self) -> Field { Err(FieldErr("provideClientKey")) } /// If Linked Data Signatures and HTTP Signatures are being used for authentication and authorization, this endpoint specifies a URI at which a client key may be signed by the actor's key for a time window to act on behalf of the actor in interacting with foreign servers. - fn sign_client_key(&self) -> Field<&str> { Err(FieldErr("signClientKey")) } + fn sign_client_key(&self) -> Field { Err(FieldErr("signClientKey")) } /// An optional endpoint used for wide delivery of publicly addressed activities and activities sent to followers. sharedInbox endpoints SHOULD also be publicly readable OrderedCollection objects containing objects addressed to the Public special collection. Reading from the sharedInbox endpoint MUST NOT present objects which are not addressed to the Public endpoint. - fn shared_inbox(&self) -> Field<&str> { Err(FieldErr("sharedInbox")) } + fn shared_inbox(&self) -> Field { Err(FieldErr("sharedInbox")) } } pub trait ActorMut : ObjectMut { @@ -82,7 +82,7 @@ pub trait ActorMut : ObjectMut { type Endpoints : Endpoints; fn set_actor_type(self, val: Option) -> Self; - fn set_preferred_username(self, val: Option<&str>) -> Self; + fn set_preferred_username(self, val: Option) -> Self; fn set_inbox(self, val: Node) -> Self; fn set_outbox(self, val: Node) -> Self; fn set_following(self, val: Node) -> Self; @@ -122,17 +122,17 @@ pub trait ActorMut : ObjectMut { pub trait EndpointsMut : ObjectMut { /// Endpoint URI so this actor's clients may access remote ActivityStreams objects which require authentication to access. To use this endpoint, the client posts an x-www-form-urlencoded id parameter with the value being the id of the requested ActivityStreams object. - fn set_proxy_url(self, val: Option<&str>) -> Self; + fn set_proxy_url(self, val: Option) -> Self; /// If OAuth 2.0 bearer tokens [RFC6749] [RFC6750] are being used for authenticating client to server interactions, this endpoint specifies a URI at which a browser-authenticated user may obtain a new authorization grant. - fn set_oauth_authorization_endpoint(self, val: Option<&str>) -> Self; + fn set_oauth_authorization_endpoint(self, val: Option) -> Self; /// If OAuth 2.0 bearer tokens [RFC6749] [RFC6750] are being used for authenticating client to server interactions, this endpoint specifies a URI at which a client may acquire an access token. - fn set_oauth_token_endpoint(self, val: Option<&str>) -> Self; + fn set_oauth_token_endpoint(self, val: Option) -> Self; /// If Linked Data Signatures and HTTP Signatures are being used for authentication and authorization, this endpoint specifies a URI at which browser-authenticated users may authorize a client's public key for client to server interactions. - fn set_provide_client_key(self, val: Option<&str>) -> Self; + fn set_provide_client_key(self, val: Option) -> Self; /// If Linked Data Signatures and HTTP Signatures are being used for authentication and authorization, this endpoint specifies a URI at which a client key may be signed by the actor's key for a time window to act on behalf of the actor in interacting with foreign servers. - fn set_sign_client_key(self, val: Option<&str>) -> Self; + fn set_sign_client_key(self, val: Option) -> Self; /// An optional endpoint used for wide delivery of publicly addressed activities and activities sent to followers. sharedInbox endpoints SHOULD also be publicly readable OrderedCollection objects containing objects addressed to the Public special collection. Reading from the sharedInbox endpoint MUST NOT present objects which are not addressed to the Public endpoint. - fn set_shared_inbox(self, val: Option<&str>) -> Self; + fn set_shared_inbox(self, val: Option) -> Self; } #[cfg(feature = "unstructured")] @@ -141,7 +141,7 @@ impl Actor for serde_json::Value { type Endpoints = serde_json::Value; crate::getter! { actorType -> type ActorType } - crate::getter! { preferredUsername -> &str } + crate::getter! { preferredUsername -> String } crate::getter! { inbox -> node Self::Collection } crate::getter! { outbox -> node Self::Collection } crate::getter! { following -> node Self::Collection } @@ -181,12 +181,12 @@ impl Actor for serde_json::Value { #[cfg(feature = "unstructured")] impl Endpoints for serde_json::Value { - crate::getter! { proxyUrl -> &str } - crate::getter! { oauthAuthorizationEndpoint -> &str } - crate::getter! { oauthTokenEndpoint -> &str } - crate::getter! { provideClientKey -> &str } - crate::getter! { signClientKey -> &str } - crate::getter! { sharedInbox -> &str } + crate::getter! { proxyUrl -> String } + crate::getter! { oauthAuthorizationEndpoint -> String } + crate::getter! { oauthTokenEndpoint -> String } + crate::getter! { provideClientKey -> String } + crate::getter! { signClientKey -> String } + crate::getter! { sharedInbox -> String } } #[cfg(feature = "unstructured")] @@ -195,7 +195,7 @@ impl ActorMut for serde_json::Value { type Endpoints = serde_json::Value; crate::setter! { actor_type -> type ActorType } - crate::setter! { preferredUsername -> &str } + crate::setter! { preferredUsername -> String } crate::setter! { inbox -> node Self::Collection } crate::setter! { outbox -> node Self::Collection } crate::setter! { following -> node Self::Collection } @@ -236,10 +236,10 @@ impl ActorMut for serde_json::Value { #[cfg(feature = "unstructured")] impl EndpointsMut for serde_json::Value { - crate::setter! { proxyUrl -> &str } - crate::setter! { oauthAuthorizationEndpoint -> &str } - crate::setter! { oauthTokenEndpoint -> &str } - crate::setter! { provideClientKey -> &str } - crate::setter! { signClientKey -> &str } - crate::setter! { sharedInbox -> &str } + crate::setter! { proxyUrl -> String } + crate::setter! { oauthAuthorizationEndpoint -> String } + crate::setter! { oauthTokenEndpoint -> String } + crate::setter! { provideClientKey -> String } + crate::setter! { signClientKey -> String } + crate::setter! { sharedInbox -> String } } diff --git a/apb/src/types/object/mod.rs b/apb/src/types/object/mod.rs index f1bc20e..d0104db 100644 --- a/apb/src/types/object/mod.rs +++ b/apb/src/types/object/mod.rs @@ -52,14 +52,14 @@ pub trait Object : Base { /// The content or textual representation of the Object encoded as a JSON string. By default, the value of content is HTML /// The mediaType property can be used in the object to indicate a different content type /// The content MAY be expressed using multiple language-tagged values - fn content(&self) -> Field<&str> { Err(FieldErr("content")) } // TODO handle language maps + fn content(&self) -> Field { Err(FieldErr("content")) } // TODO handle language maps /// Identifies the context within which the object exists or an activity was performed /// The notion of "context" used is intentionally vague /// The intended function is to serve as a means of grouping objects and activities that share a common originating context or purpose /// An example could be all activities relating to a common project or event fn context(&self) -> Node { Node::Empty } /// A simple, human-readable, plain-text name for the object. HTML markup MUST NOT be included. The name MAY be expressed using multiple language-tagged values - fn name(&self) -> Field<&str> { Err(FieldErr("name")) } // also in link // TODO handle language maps + fn name(&self) -> Field { Err(FieldErr("name")) } // also in link // TODO handle language maps /// The date and time describing the actual or expected ending time of the object /// When used with an Activity object, for instance, the endTime property specifies the moment the activity concluded or is expected to conclude. fn end_time(&self) -> Field> { Err(FieldErr("endTime")) } @@ -89,7 +89,7 @@ pub trait Object : Base { /// When used with an Activity object, for instance, the startTime property specifies the moment the activity began or is scheduled to begin. fn start_time(&self) -> Field> { Err(FieldErr("startTime")) } /// A natural language summarization of the object encoded as HTML. Multiple language tagged summaries MAY be provided - fn summary(&self) -> Field<&str> { Err(FieldErr("summary")) } + fn summary(&self) -> Field { Err(FieldErr("summary")) } /// One or more "tags" that have been associated with an objects. A tag can be any kind of Object /// The key difference between attachment and tag is that the former implies association by inclusion, while the latter implies associated by reference // TODO technically this is an object? but spec says that it works my reference, idk @@ -107,10 +107,10 @@ pub trait Object : Base { /// When used on a Link, identifies the MIME media type of the referenced resource. /// When used on an Object, identifies the MIME media type of the value of the content property. /// If not specified, the content property is assumed to contain text/html content. - fn media_type(&self) -> Field<&str> { Err(FieldErr("mediaType")) } // also in link + fn media_type(&self) -> Field { Err(FieldErr("mediaType")) } // also in link /// When the object describes a time-bound resource, such as an audio or video, a meeting, etc, the duration property indicates the object's approximate duration. /// The value MUST be expressed as an xsd:duration as defined by [ xmlschema11-2], section 3.3.6 (e.g. a period of 5 seconds is represented as "PT5S"). - fn duration(&self) -> Field<&str> { Err(FieldErr("duration")) } // TODO how to parse xsd:duration ? + fn duration(&self) -> Field { Err(FieldErr("duration")) } // TODO how to parse xsd:duration ? #[cfg(feature = "activitypub-miscellaneous-terms")] fn sensitive(&self) -> Field { Err(FieldErr("sensitive")) } @@ -129,7 +129,7 @@ pub trait Object : Base { fn as_document(&self) -> Result<&Self::Document, FieldErr> { Err(FieldErr("type")) } #[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?! - fn value(&self) -> Field<&str> { Err(FieldErr("value")) } + fn value(&self) -> Field { Err(FieldErr("value")) } } pub trait ObjectMut : BaseMut { @@ -143,9 +143,9 @@ pub trait ObjectMut : BaseMut { fn set_attachment(self, val: Node) -> Self; fn set_attributed_to(self, val: Node) -> Self; fn set_audience(self, val: Node) -> Self; - fn set_content(self, val: Option<&str>) -> Self; // TODO handle language maps + fn set_content(self, val: Option) -> Self; // TODO handle language maps fn set_context(self, val: Node) -> Self; - fn set_name(self, val: Option<&str>) -> Self; // also in link // TODO handle language maps + fn set_name(self, val: Option) -> Self; // also in link // TODO handle language maps fn set_end_time(self, val: Option>) -> Self; fn set_generator(self, val: Node) -> Self; fn set_icon(self, val: Node) -> Self; @@ -159,15 +159,15 @@ pub trait ObjectMut : BaseMut { fn set_likes(self, val: Node) -> Self; fn set_shares(self, val: Node) -> Self; fn set_start_time(self, val: Option>) -> Self; - fn set_summary(self, val: Option<&str>) -> Self; + fn set_summary(self, val: Option) -> Self; fn set_tag(self, val: Node) -> Self; fn set_url(self, val: Node) -> Self; fn set_to(self, val: Node) -> Self; fn set_bto(self, val: Node) -> Self; fn set_cc(self, val: Node) -> Self; fn set_bcc(self, val: Node) -> Self; - fn set_media_type(self, val: Option<&str>) -> Self; // also in link - fn set_duration(self, val: Option<&str>) -> Self; // TODO how to parse xsd:duration ? + fn set_media_type(self, val: Option) -> Self; // also in link + fn set_duration(self, val: Option) -> Self; // TODO how to parse xsd:duration ? #[cfg(feature = "activitypub-miscellaneous-terms")] fn set_sensitive(self, val: Option) -> Self; @@ -181,7 +181,7 @@ pub trait ObjectMut : BaseMut { fn set_conversation(self, val: Node) -> Self; #[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?! - fn set_value(self, val: Option<&str>) -> Self; + fn set_value(self, val: Option) -> Self; } #[cfg(feature = "unstructured")] @@ -197,9 +197,9 @@ impl Object for serde_json::Value { crate::getter! { attachment -> node ::Object } crate::getter! { attributedTo -> node Self::Actor } crate::getter! { audience -> node Self::Actor } - crate::getter! { content -> &str } + crate::getter! { content -> String } crate::getter! { context -> node ::Object } - crate::getter! { name -> &str } + crate::getter! { name -> String } crate::getter! { endTime -> chrono::DateTime } crate::getter! { generator -> node Self::Actor } crate::getter! { icon -> node Self::Document } @@ -213,14 +213,14 @@ impl Object for serde_json::Value { crate::getter! { likes -> node Self::Collection } crate::getter! { shares -> node Self::Collection } crate::getter! { startTime -> chrono::DateTime } - crate::getter! { summary -> &str } + crate::getter! { summary -> String } crate::getter! { tag -> node ::Object } crate::getter! { to -> node Self::Link } crate::getter! { bto -> node Self::Link } crate::getter! { cc -> node Self::Link } crate::getter! { bcc -> node Self::Link } - crate::getter! { mediaType -> &str } - crate::getter! { duration -> &str } + crate::getter! { mediaType -> String } + crate::getter! { duration -> String } crate::getter! { url -> node Self::Link } #[cfg(feature = "activitypub-miscellaneous-terms")] @@ -235,7 +235,7 @@ impl Object for serde_json::Value { crate::getter! { conversation -> node ::Object } #[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?! - crate::getter! { value -> &str } + crate::getter! { value -> String } fn as_activity(&self) -> Result<&Self::Activity, FieldErr> { match self.object_type()? { @@ -278,9 +278,9 @@ impl ObjectMut for serde_json::Value { crate::setter! { attachment -> node ::Object } crate::setter! { attributedTo -> node Self::Actor } crate::setter! { audience -> node Self::Actor } - crate::setter! { content -> &str } + crate::setter! { content -> String } crate::setter! { context -> node ::Object } - crate::setter! { name -> &str } + crate::setter! { name -> String } crate::setter! { endTime -> chrono::DateTime } crate::setter! { generator -> node Self::Actor } crate::setter! { icon -> node Self::Document } @@ -294,14 +294,14 @@ impl ObjectMut for serde_json::Value { crate::setter! { likes -> node Self::Collection } crate::setter! { shares -> node Self::Collection } crate::setter! { startTime -> chrono::DateTime } - crate::setter! { summary -> &str } + crate::setter! { summary -> String } crate::setter! { tag -> node ::Object } crate::setter! { to -> node Self::Link } crate::setter! { bto -> node Self::Link} crate::setter! { cc -> node Self::Link } crate::setter! { bcc -> node Self::Link } - crate::setter! { mediaType -> &str } - crate::setter! { duration -> &str } + crate::setter! { mediaType -> String } + crate::setter! { duration -> String } crate::setter! { url -> node Self::Link } #[cfg(feature = "activitypub-miscellaneous-terms")] @@ -316,5 +316,5 @@ impl ObjectMut for serde_json::Value { crate::setter! { conversation -> node ::Object } #[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?! - crate::setter! { value -> &str } + crate::setter! { value -> String } }