diff --git a/src/activitystream/macros.rs b/src/activitystream/macros.rs index 7366019..e0c800f 100644 --- a/src/activitystream/macros.rs +++ b/src/activitystream/macros.rs @@ -100,6 +100,12 @@ macro_rules! getter { } }; + ($name:ident -> bool) => { + fn $name(&self) -> Option { + self.get(stringify!($name))?.as_bool() + } + }; + ($name:ident -> &str) => { fn $name(&self) -> Option<&str> { self.get(stringify!($name))?.as_str() @@ -185,6 +191,17 @@ macro_rules! getter { #[macro_export] macro_rules! setter { + ($name:ident -> bool) => { + paste::item! { + fn [< set_$name >](mut self, val: Option) -> Self { + $crate::activitystream::macros::set_maybe_value( + &mut self, stringify!($name), val.map(|x| serde_json::Value::Bool(x)) + ); + self + } + } + }; + ($name:ident -> &str) => { paste::item! { fn [< set_$name >](mut self, val: Option<&str>) -> Self { diff --git a/src/activitystream/object/actor.rs b/src/activitystream/object/actor.rs index b175827..afd8c09 100644 --- a/src/activitystream/object/actor.rs +++ b/src/activitystream/object/actor.rs @@ -24,6 +24,8 @@ pub trait Actor : super::Object { fn streams(&self) -> Node { Node::empty() } fn endpoints(&self) -> Option> { None } fn public_key(&self) -> Node { Node::empty() } + // idk about this? everyone has it but AP doesn't mention it + fn discoverable(&self) -> Option { None } } pub trait ActorMut : super::ObjectMut { @@ -37,6 +39,7 @@ pub trait ActorMut : super::ObjectMut { fn set_streams(self, val: Node) -> Self; fn set_endpoints(self, val: Option>) -> Self; fn set_public_key(self, val: Node) -> Self; + fn set_discoverable(self, val: Option) -> Self; } impl Actor for serde_json::Value { @@ -49,6 +52,7 @@ impl Actor for serde_json::Value { getter! { liked -> node impl Collection } getter! { streams -> node impl Collection } getter! { public_key::publicKey -> node impl PublicKey } + getter! { discoverable -> bool } fn endpoints(&self) -> Option> { todo!() @@ -65,6 +69,7 @@ impl ActorMut for serde_json::Value { setter! { liked -> node impl Collection } setter! { streams -> node impl Collection } setter! { public_key::publicKey -> node impl PublicKey } + setter! { discoverable -> bool } fn set_endpoints(self, _val: Option>) -> Self { todo!()