use crate::{activitystream::Node, getter, setter, strenum}; use super::collection::Collection; strenum! { pub enum ActorType { Application, Group, Organization, Person, Object; }; } pub trait Actor : super::Object { fn actor_type(&self) -> Option { None } fn preferred_username(&self) -> Option<&str> { None } fn inbox(&self) -> Node; fn outbox(&self) -> Node; fn following(&self) -> Node { Node::Empty:: } fn followers(&self) -> Node { Node::Empty:: } fn liked(&self) -> Node { Node::Empty:: } fn streams(&self) -> Node { Node::Empty:: } fn endpoints(&self) -> Option> { None } } pub trait ActorMut : super::ObjectMut { fn set_actor_type(&mut self, val: Option) -> &mut Self; fn set_preferred_username(&mut self, val: Option<&str>) -> &mut Self; fn set_inbox(&mut self, val: Node) -> &mut Self; fn set_outbox(&mut self, val: Node) -> &mut Self; fn set_following(&mut self, val: Node) -> &mut Self; fn set_followers(&mut self, val: Node) -> &mut Self; fn set_liked(&mut self, val: Node) -> &mut Self; fn set_streams(&mut self, val: Node) -> &mut Self; fn set_endpoints(&mut self, val: Option>) -> &mut Self; } impl Actor for serde_json::Value { getter! { actor_type -> type ActorType } getter! { preferred_username::preferredUsername -> &str } getter! { inbox -> node impl Collection } getter! { outbox -> node impl Collection } getter! { following -> node impl Collection } getter! { followers -> node impl Collection } getter! { liked -> node impl Collection } getter! { streams -> node impl Collection } fn endpoints(&self) -> Option> { todo!() } } impl ActorMut for serde_json::Value { setter! { actor_type -> type ActorType } setter! { preferred_username::preferredUsername -> &str } setter! { inbox -> node impl Collection } setter! { outbox -> node impl Collection } setter! { following -> node impl Collection } setter! { followers -> node impl Collection } setter! { liked -> node impl Collection } setter! { streams -> node impl Collection } fn set_endpoints(&mut self, val: Option>) -> &mut Self { todo!() } }