1
0
Fork 0
forked from alemi/upub

chore: Mut traits take owned self rather than &mut

This commit is contained in:
əlemi 2024-03-21 00:04:01 +01:00
parent a385d4a226
commit bf8cd97c8f
Signed by: alemi
GPG key ID: A4895B84D311642C
19 changed files with 182 additions and 154 deletions

View file

@ -17,16 +17,15 @@ pub struct Page {
}
pub async fn view(State(ctx): State<Context>) -> Result<Json<serde_json::Value>, StatusCode> {
let mut base = activitystream::object();
base
.set_actor_type(Some(ActorType::Application))
.set_id(Some(&url!(ctx, "")))
.set_name(Some("μpub"))
.set_summary(Some("micro social network, federated"))
.set_inbox(Node::link(&url!(ctx, "/inbox")))
.set_outbox(Node::link(&url!(ctx, "/outbox")));
Ok(Json(base))
Ok(Json(
activitystream::object()
.set_actor_type(Some(ActorType::Application))
.set_id(Some(&url!(ctx, "")))
.set_name(Some("μpub"))
.set_summary(Some("micro social network, federated"))
.set_inbox(Node::link(url!(ctx, "/inbox")))
.set_outbox(Node::link(url!(ctx, "/outbox")))
))
}
pub async fn inbox(State(ctx) : State<Context>, Json(object): Json<serde_json::Value>) -> Result<Json<serde_json::Value>, StatusCode> {

View file

@ -54,24 +54,24 @@ pub async fn outbox(
.into_iter()
.map(|i| i.underlying_json_object())
.collect();
let mut obj = activitystream::object();
obj
// TODO set id, calculate uri from given args
.set_collection_type(Some(CollectionType::OrderedCollectionPage))
.set_part_of(Node::link(&url!(ctx, "/users/{id}/outbox")))
.set_next(Node::link(&url!(ctx, "/users/{id}/outbox?page=true&max_id={next}")))
.set_ordered_items(Node::array(items));
Ok(Json(obj))
Ok(Json(
activitystream::object()
// TODO set id, calculate uri from given args
.set_collection_type(Some(CollectionType::OrderedCollectionPage))
.set_part_of(Node::link(url!(ctx, "/users/{id}/outbox")))
.set_next(Node::link(url!(ctx, "/users/{id}/outbox?page=true&max_id={next}")))
.set_ordered_items(Node::array(items))
))
},
}
} else {
let mut obj = crate::activitystream::object();
obj
.set_id(Some(&url!(ctx, "/users/{id}/outbox")))
.set_collection_type(Some(CollectionType::OrderedCollection))
.set_first(Node::link(&url!(ctx, "/users/{id}/outbox?page=true")));
Ok(Json(obj.underlying_json_object()))
Ok(Json(
crate::activitystream::object()
.set_id(Some(&url!(ctx, "/users/{id}/outbox")))
.set_collection_type(Some(CollectionType::OrderedCollection))
.set_first(Node::link(url!(ctx, "/users/{id}/outbox?page=true")))
))
}
}

View file

@ -1,4 +1,4 @@
use crate::strenum;
use crate::{getter, setter, strenum};
strenum! {
pub enum LinkType {
@ -10,23 +10,23 @@ strenum! {
pub trait Link : super::Base {
fn href(&self) -> &str;
fn rel(&self) -> Option<&str> { None }
fn media_type(&self) -> Option<&str> { None } // also in obj
fn name(&self) -> Option<&str> { None } // also in obj
fn link_media_type(&self) -> Option<&str> { None } // also in obj
fn link_name(&self) -> Option<&str> { None } // also in obj
fn hreflang(&self) -> Option<&str> { None }
fn height(&self) -> Option<&str> { None }
fn width(&self) -> Option<&str> { None }
fn preview(&self) -> Option<&str> { None } // also in obj
fn height(&self) -> Option<u64> { None }
fn width(&self) -> Option<u64> { None }
fn link_preview(&self) -> Option<&str> { None } // also in obj
}
pub trait LinkMut : super::BaseMut {
fn set_href(&mut self, href: &str) -> &mut Self;
fn set_rel(&mut self, val: Option<&str>) -> &mut Self;
fn set_media_type(&mut self, val: Option<&str>) -> &mut Self; // also in obj
fn set_name(&mut self, val: Option<&str>) -> &mut Self; // also in obj
fn set_hreflang(&mut self, val: Option<&str>) -> &mut Self;
fn set_height(&mut self, val: Option<&str>) -> &mut Self;
fn set_width(&mut self, val: Option<&str>) -> &mut Self;
fn set_preview(&mut self, val: Option<&str>) -> &mut Self; // also in obj
fn set_href(self, href: &str) -> Self;
fn set_rel(self, val: Option<&str>) -> Self;
fn set_link_media_type(self, val: Option<&str>) -> Self; // also in obj
fn set_link_name(self, val: Option<&str>) -> Self; // also in obj
fn set_hreflang(self, val: Option<&str>) -> Self;
fn set_height(self, val: Option<u64>) -> Self;
fn set_width(self, val: Option<u64>) -> Self;
fn set_link_preview(self, val: Option<&str>) -> Self; // also in obj
}
impl Link for String {
@ -36,19 +36,51 @@ impl Link for String {
}
impl Link for serde_json::Value {
// TODO this is unchecked and can panic
// TODO this can fail, but it should never do!
fn href(&self) -> &str {
match self {
serde_json::Value::String(x) => x,
serde_json::Value::Object(map) =>
map.get("href")
.unwrap()
.as_str()
.unwrap(),
_ => panic!("invalid value for Link"),
.map(|h| h.as_str().unwrap_or(""))
.unwrap_or(""),
_ => {
tracing::error!("failed getting href on invalid json Link object");
""
},
}
}
// ... TODO!
getter! { rel -> &str }
getter! { link_media_type::mediaType -> &str }
getter! { link_name::name -> &str }
getter! { hreflang -> &str }
getter! { height -> u64 }
getter! { width -> u64 }
getter! { link_preview::preview -> &str }
}
impl LinkMut for serde_json::Value {
// TODO this can fail, but it should never do!
fn set_href(mut self, href: &str) -> Self {
match &mut self {
serde_json::Value::String(x) => *x = href.to_string(),
serde_json::Value::Object(map) => {
map.insert(
"href".to_string(),
serde_json::Value::String(href.to_string())
);
},
_ => tracing::error!("failed setting href on invalid json Link object"),
}
self
}
setter! { rel -> &str }
setter! { link_media_type::mediaType -> &str }
setter! { link_name::name -> &str }
setter! { hreflang -> &str }
setter! { height -> u64 }
setter! { width -> u64 }
setter! { link_preview::preview -> &str }
}

View file

@ -187,9 +187,9 @@ macro_rules! getter {
macro_rules! setter {
($name:ident -> &str) => {
paste::item! {
fn [< set_$name >](&mut self, val: Option<&str>) -> &mut Self {
fn [< set_$name >](mut self, val: Option<&str>) -> Self {
$crate::activitystream::macros::set_maybe_value(
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.to_string()))
);
self
}
@ -198,9 +198,9 @@ macro_rules! setter {
($name:ident::$rename:ident -> &str) => {
paste::item! {
fn [< set_$name >](&mut self, val: Option<&str>) -> &mut Self {
fn [< set_$name >](mut self, val: Option<&str>) -> Self {
$crate::activitystream::macros::set_maybe_value(
self, stringify!($rename), val.map(|x| serde_json::Value::String(x.to_string()))
&mut self, stringify!($rename), val.map(|x| serde_json::Value::String(x.to_string()))
);
self
}
@ -209,9 +209,9 @@ macro_rules! setter {
($name:ident -> u64) => {
paste::item! {
fn [< set_$name >](&mut self, val: Option<u64>) -> &mut Self {
fn [< set_$name >](mut self, val: Option<u64>) -> Self {
$crate::activitystream::macros::set_maybe_value(
self, stringify!($name), val.map(|x| serde_json::Value::Number(serde_json::Number::from(x)))
&mut self, stringify!($name), val.map(|x| serde_json::Value::Number(serde_json::Number::from(x)))
);
self
}
@ -220,9 +220,9 @@ macro_rules! setter {
($name:ident::$rename:ident -> u64) => {
paste::item! {
fn [< set_$name >](&mut self, val: Option<u64>) -> &mut Self {
fn [< set_$name >](mut self, val: Option<u64>) -> Self {
$crate::activitystream::macros::set_maybe_value(
self, stringify!($rename), val.map(|x| serde_json::Value::Number(serde_json::Number::from(x)))
&mut self, stringify!($rename), val.map(|x| serde_json::Value::Number(serde_json::Number::from(x)))
);
self
}
@ -231,9 +231,9 @@ macro_rules! setter {
($name:ident -> chrono::DateTime<chrono::Utc>) => {
paste::item! {
fn [< set_$name >](&mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> &mut Self {
fn [< set_$name >](mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> Self {
$crate::activitystream::macros::set_maybe_value(
self, stringify!($name), val.map(|x| serde_json::Value::String(x.to_rfc3339()))
&mut self, stringify!($name), val.map(|x| serde_json::Value::String(x.to_rfc3339()))
);
self
}
@ -242,9 +242,9 @@ macro_rules! setter {
($name:ident::$rename:ident -> chrono::DateTime<chrono::Utc>) => {
paste::item! {
fn [< set_$name >](&mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> &mut Self {
fn [< set_$name >](mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> Self {
$crate::activitystream::macros::set_maybe_value(
self, stringify!($rename), val.map(|x| serde_json::Value::String(x.to_rfc3339()))
&mut self, stringify!($rename), val.map(|x| serde_json::Value::String(x.to_rfc3339()))
);
self
}
@ -253,9 +253,9 @@ macro_rules! setter {
($name:ident -> node $t:ty ) => {
paste::item! {
fn [< set_$name >](&mut self, val: $crate::activitystream::Node<$t>) -> &mut Self {
fn [< set_$name >](mut self, val: $crate::activitystream::Node<$t>) -> Self {
$crate::activitystream::macros::set_maybe_node(
self, stringify!($name), val
&mut self, stringify!($name), val
);
self
}
@ -264,9 +264,9 @@ macro_rules! setter {
($name:ident::$rename:ident -> node $t:ty ) => {
paste::item! {
fn [< set_$name >](&mut self, val: $crate::activitystream::Node<$t>) -> &mut Self {
fn [< set_$name >](mut self, val: $crate::activitystream::Node<$t>) -> Self {
$crate::activitystream::macros::set_maybe_node(
self, stringify!($rename), val
&mut self, stringify!($rename), val
);
self
}
@ -275,9 +275,9 @@ macro_rules! setter {
($name:ident -> type $t:ty ) => {
paste::item! {
fn [< set_$name >](&mut self, val: Option<$t>) -> &mut Self {
fn [< set_$name >](mut self, val: Option<$t>) -> Self {
$crate::activitystream::macros::set_maybe_value(
self, "type", val.map(|x| serde_json::Value::String(x.as_ref().to_string()))
&mut self, "type", val.map(|x| serde_json::Value::String(x.as_ref().to_string()))
);
self
}

View file

@ -8,6 +8,7 @@ pub mod node;
pub use node::Node;
pub mod macros;
pub mod prelude;
use crate::{getter, setter, strenum};
@ -41,8 +42,8 @@ pub fn object() -> serde_json::Value {
}
pub trait BaseMut {
fn set_id(&mut self, val: Option<&str>) -> &mut Self;
fn set_base_type(&mut self, val: Option<BaseType>) -> &mut Self;
fn set_id(self, val: Option<&str>) -> Self;
fn set_base_type(self, val: Option<BaseType>) -> Self;
}

View file

@ -12,5 +12,5 @@ pub trait Accept : super::Activity {
}
pub trait AcceptMut : super::ActivityMut {
fn set_accept_type(&mut self, val: Option<AcceptType>) -> &mut Self;
fn set_accept_type(self, val: Option<AcceptType>) -> Self;
}

View file

@ -12,5 +12,5 @@ pub trait Ignore : super::Activity {
}
pub trait IgnoreMut : super::ActivityMut {
fn set_ignore_type(&mut self, val: Option<IgnoreType>) -> &mut Self;
fn set_ignore_type(self, val: Option<IgnoreType>) -> Self;
}

View file

@ -14,5 +14,5 @@ pub trait IntransitiveActivity : super::Activity {
}
pub trait IntransitiveActivityMut : super::ActivityMut {
fn set_intransitive_activity_type(&mut self, val: Option<IntransitiveActivityType>) -> &mut Self;
fn set_intransitive_activity_type(self, val: Option<IntransitiveActivityType>) -> Self;
}

View file

@ -52,13 +52,13 @@ pub trait Activity : super::Object {
}
pub trait ActivityMut : super::ObjectMut {
fn set_activity_type(&mut self, val: Option<ActivityType>) -> &mut Self;
fn set_actor(&mut self, val: Node<impl super::Actor>) -> &mut Self;
fn set_object(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_target(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_result(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_origin(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_instrument(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_activity_type(self, val: Option<ActivityType>) -> Self;
fn set_actor(self, val: Node<impl super::Actor>) -> Self;
fn set_object(self, val: Node<impl super::Object>) -> Self;
fn set_target(self, val: Node<impl super::Object>) -> Self;
fn set_result(self, val: Node<impl super::Object>) -> Self;
fn set_origin(self, val: Node<impl super::Object>) -> Self;
fn set_instrument(self, val: Node<impl super::Object>) -> Self;
}
impl Activity for serde_json::Value {

View file

@ -12,5 +12,5 @@ pub trait Offer : super::Activity {
}
pub trait OfferMut : super::ActivityMut {
fn set_offer_type(&mut self, val: Option<OfferType>) -> &mut Self;
fn set_offer_type(self, val: Option<OfferType>) -> Self;
}

View file

@ -12,5 +12,5 @@ pub trait Reject : super::Activity {
}
pub trait RejectMut : super::ActivityMut {
fn set_reject_type(&mut self, val: Option<RejectType>) -> &mut Self;
fn set_reject_type(self, val: Option<RejectType>) -> Self;
}

View file

@ -25,15 +25,15 @@ pub trait Actor : super::Object {
}
pub trait ActorMut : super::ObjectMut {
fn set_actor_type(&mut self, val: Option<ActorType>) -> &mut Self;
fn set_preferred_username(&mut self, val: Option<&str>) -> &mut Self;
fn set_inbox(&mut self, val: Node<impl Collection>) -> &mut Self;
fn set_outbox(&mut self, val: Node<impl Collection>) -> &mut Self;
fn set_following(&mut self, val: Node<impl Collection>) -> &mut Self;
fn set_followers(&mut self, val: Node<impl Collection>) -> &mut Self;
fn set_liked(&mut self, val: Node<impl Collection>) -> &mut Self;
fn set_streams(&mut self, val: Node<impl Collection>) -> &mut Self;
fn set_endpoints(&mut self, val: Option<serde_json::Map<String, String>>) -> &mut Self;
fn set_actor_type(self, val: Option<ActorType>) -> Self;
fn set_preferred_username(self, val: Option<&str>) -> Self;
fn set_inbox(self, val: Node<impl Collection>) -> Self;
fn set_outbox(self, val: Node<impl Collection>) -> Self;
fn set_following(self, val: Node<impl Collection>) -> Self;
fn set_followers(self, val: Node<impl Collection>) -> Self;
fn set_liked(self, val: Node<impl Collection>) -> Self;
fn set_streams(self, val: Node<impl Collection>) -> Self;
fn set_endpoints(self, val: Option<serde_json::Map<String, String>>) -> Self;
}
impl Actor for serde_json::Value {
@ -61,7 +61,7 @@ impl ActorMut for serde_json::Value {
setter! { liked -> node impl Collection }
setter! { streams -> node impl Collection }
fn set_endpoints(&mut self, val: Option<serde_json::Map<String, String>>) -> &mut Self {
fn set_endpoints(self, _val: Option<serde_json::Map<String, String>>) -> Self {
todo!()
}
}

View file

@ -25,14 +25,13 @@ pub trait Collection : super::Object {
}
pub trait CollectionMut : super::ObjectMut {
fn set_collection_type(&mut self, val: Option<CollectionType>) -> &mut Self;
fn set_total_items(&mut self, val: Option<u64>) -> &mut Self;
fn set_current(&mut self, val: Node<impl CollectionPage>) -> &mut Self;
fn set_first(&mut self, val: Node<impl CollectionPage>) -> &mut Self;
fn set_last(&mut self, val: Node<impl CollectionPage>) -> &mut Self;
fn set_items(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_ordered_items(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_collection_type(self, val: Option<CollectionType>) -> Self;
fn set_total_items(self, val: Option<u64>) -> Self;
fn set_current(self, val: Node<impl CollectionPage>) -> Self;
fn set_first(self, val: Node<impl CollectionPage>) -> Self;
fn set_last(self, val: Node<impl CollectionPage>) -> Self;
fn set_items(self, val: Node<impl super::Object>) -> Self;
fn set_ordered_items(self, val: Node<impl super::Object>) -> Self;
}
impl Collection for serde_json::Value {

View file

@ -7,9 +7,9 @@ pub trait CollectionPage : super::Collection {
}
pub trait CollectionPageMut : super::CollectionMut {
fn set_part_of(&mut self, val: Node<impl super::Collection>) -> &mut Self;
fn set_next(&mut self, val: Node<impl CollectionPage>) -> &mut Self;
fn set_prev(&mut self, val: Node<impl CollectionPage>) -> &mut Self;
fn set_part_of(self, val: Node<impl super::Collection>) -> Self;
fn set_next(self, val: Node<impl CollectionPage>) -> Self;
fn set_prev(self, val: Node<impl CollectionPage>) -> Self;
}
impl CollectionPage for serde_json::Value {

View file

@ -15,13 +15,10 @@ pub trait Document : super::Object {
}
pub trait DocumentMut : super::ObjectMut {
fn set_document_type(&mut self, val: Option<DocumentType>) -> &mut Self;
fn set_document_type(self, val: Option<DocumentType>) -> Self;
}
pub trait Image : Document {}
impl Document for serde_json::Value {}
impl Image for serde_json::Value {}

View file

@ -9,7 +9,7 @@ pub mod relationship;
use crate::{getter, setter, strenum};
use super::Node;
use super::{Link, Node};
use actor::{Actor, ActorType};
use document::{Image, DocumentType};
@ -56,42 +56,42 @@ pub trait Object : super::Base {
fn tag(&self) -> Node<impl Object> { Node::Empty::<serde_json::Value> }
fn updated(&self) -> Option<chrono::DateTime<chrono::Utc>> { None }
fn url(&self) -> Option<Vec<impl super::Link>> { None::<Vec<serde_json::Value>> }
fn to(&self) -> Node<impl Object> { Node::Empty::<serde_json::Value> }
fn bto(&self) -> Node<impl Object> { Node::Empty::<serde_json::Value> }
fn cc(&self) -> Node<impl Object> { Node::Empty::<serde_json::Value> }
fn bcc(&self) -> Node<impl Object> { Node::Empty::<serde_json::Value> }
fn to(&self) -> Node<impl Link> { Node::Empty::<serde_json::Value> }
fn bto(&self) -> Node<impl Link> { Node::Empty::<serde_json::Value> }
fn cc(&self) -> Node<impl Link> { Node::Empty::<serde_json::Value> }
fn bcc(&self) -> Node<impl Link> { Node::Empty::<serde_json::Value> }
fn media_type(&self) -> Option<&str> { None } // also in link
fn duration(&self) -> Option<&str> { None } // TODO how to parse xsd:duration ?
}
pub trait ObjectMut : super::BaseMut {
fn set_object_type(&mut self, val: Option<ObjectType>) -> &mut Self;
fn set_attachment(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_attributed_to(&mut self, val: Node<impl Actor>) -> &mut Self;
fn set_audience(&mut self, val: Node<impl Actor>) -> &mut Self;
fn set_content(&mut self, val: Option<&str>) -> &mut Self; // TODO handle language maps
fn set_context(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_name(&mut self, val: Option<&str>) -> &mut Self; // also in link // TODO handle language maps
fn set_end_time(&mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> &mut Self;
fn set_generator(&mut self, val: Node<impl Actor>) -> &mut Self;
fn set_icon(&mut self, val: Node<impl Image>) -> &mut Self;
fn set_image(&mut self, val: Node<impl Image>) -> &mut Self;
fn set_in_reply_to(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_location(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_preview(&mut self, val: Node<impl Object>) -> &mut Self; // also in link
fn set_published(&mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> &mut Self;
fn set_replies(&mut self, val: Node<impl Collection>) -> &mut Self;
fn set_start_time(&mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> &mut Self;
fn set_summary(&mut self, val: Option<&str>) -> &mut Self;
fn set_tag(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_updated(&mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> &mut Self;
fn set_url(&mut self, val: Option<Vec<impl super::Link>>) -> &mut Self;
fn set_to(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_bto(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_cc(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_bcc(&mut self, val: Node<impl Object>) -> &mut Self;
fn set_media_type(&mut self, val: Option<&str>) -> &mut Self; // also in link
fn set_duration(&mut self, val: Option<&str>) -> &mut Self; // TODO how to parse xsd:duration ?
fn set_object_type(self, val: Option<ObjectType>) -> Self;
fn set_attachment(self, val: Node<impl Object>) -> Self;
fn set_attributed_to(self, val: Node<impl Actor>) -> Self;
fn set_audience(self, val: Node<impl Actor>) -> Self;
fn set_content(self, val: Option<&str>) -> Self; // TODO handle language maps
fn set_context(self, val: Node<impl Object>) -> Self;
fn set_name(self, val: Option<&str>) -> Self; // also in link // TODO handle language maps
fn set_end_time(self, val: Option<chrono::DateTime<chrono::Utc>>) -> Self;
fn set_generator(self, val: Node<impl Actor>) -> Self;
fn set_icon(self, val: Node<impl Image>) -> Self;
fn set_image(self, val: Node<impl Image>) -> Self;
fn set_in_reply_to(self, val: Node<impl Object>) -> Self;
fn set_location(self, val: Node<impl Object>) -> Self;
fn set_preview(self, val: Node<impl Object>) -> Self; // also in link
fn set_published(self, val: Option<chrono::DateTime<chrono::Utc>>) -> Self;
fn set_replies(self, val: Node<impl Collection>) -> Self;
fn set_start_time(self, val: Option<chrono::DateTime<chrono::Utc>>) -> Self;
fn set_summary(self, val: Option<&str>) -> Self;
fn set_tag(self, val: Node<impl Object>) -> Self;
fn set_updated(self, val: Option<chrono::DateTime<chrono::Utc>>) -> Self;
fn set_url(self, val: Option<Vec<impl super::Link>>) -> Self;
fn set_to(self, val: Node<impl Link>) -> Self;
fn set_bto(self, val: Node<impl Link>) -> Self;
fn set_cc(self, val: Node<impl Link>) -> Self;
fn set_bcc(self, val: Node<impl Link>) -> 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 ?
}
impl Object for serde_json::Value {
@ -116,10 +116,10 @@ impl Object for serde_json::Value {
getter! { summary -> &str }
getter! { tag -> node impl Object }
getter! { updated -> chrono::DateTime<chrono::Utc> }
getter! { to -> node impl Object }
getter! { bto -> node impl Object }
getter! { cc -> node impl Object }
getter! { bcc -> node impl Object }
getter! { to -> node impl Link }
getter! { bto -> node impl Link }
getter! { cc -> node impl Link }
getter! { bcc -> node impl Link }
getter! { media_type -> &str }
getter! { duration -> &str }
@ -155,14 +155,14 @@ impl ObjectMut for serde_json::Value {
setter! { summary -> &str }
setter! { tag -> node impl Object }
setter! { updated -> chrono::DateTime<chrono::Utc> }
setter! { to -> node impl Object }
setter! { bto -> node impl Object}
setter! { cc -> node impl Object }
setter! { bcc -> node impl Object }
setter! { to -> node impl Link }
setter! { bto -> node impl Link}
setter! { cc -> node impl Link }
setter! { bcc -> node impl Link }
setter! { media_type -> &str }
setter! { duration -> &str }
fn set_url(&mut self, _val: Option<Vec<impl super::Link>>) -> &mut Self {
fn set_url(self, _val: Option<Vec<impl super::Link>>) -> Self {
todo!()
}
}

View file

@ -8,10 +8,10 @@ pub trait Place : super::Object {
}
pub trait PlaceMut : super::ObjectMut {
fn set_accuracy(&mut self, val: Option<f64>) -> &mut Self;
fn set_altitude(&mut self, val: Option<f64>) -> &mut Self;
fn set_latitude(&mut self, val: Option<f64>) -> &mut Self;
fn set_longitude(&mut self, val: Option<f64>) -> &mut Self;
fn set_radius(&mut self, val: Option<f64>) -> &mut Self;
fn set_units(&mut self, val: Option<&str>) -> &mut Self;
fn set_accuracy(self, val: Option<f64>) -> Self;
fn set_altitude(self, val: Option<f64>) -> Self;
fn set_latitude(self, val: Option<f64>) -> Self;
fn set_longitude(self, val: Option<f64>) -> Self;
fn set_radius(self, val: Option<f64>) -> Self;
fn set_units(self, val: Option<&str>) -> Self;
}

View file

@ -7,9 +7,9 @@ pub trait Relationship : super::Object {
}
pub trait RelationshipMut : super::ObjectMut {
fn set_subject(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_relationship(&mut self, val: Option<&str>) -> &mut Self; // TODO what does this mean???
fn set_object(&mut self, val: Node<impl super::Object>) -> &mut Self;
fn set_subject(self, val: Node<impl super::Object>) -> Self;
fn set_relationship(self, val: Option<&str>) -> Self; // TODO what does this mean???
fn set_object(self, val: Node<impl super::Object>) -> Self;
}
impl Relationship for serde_json::Value {

View file

@ -4,8 +4,8 @@ pub trait Tombstone : super::Object {
}
pub trait TombstoneMut : super::ObjectMut {
fn set_former_type(&mut self, val: Option<super::super::BaseType>) -> &mut Self;
fn set_deleted(&mut self, val: Option<chrono::DateTime<chrono::Utc>>) -> &mut Self;
fn set_former_type(self, val: Option<super::super::BaseType>) -> Self;
fn set_deleted(self, val: Option<chrono::DateTime<chrono::Utc>>) -> Self;
}
impl Tombstone for serde_json::Value {