1
0
Fork 0
forked from alemi/upub

fix(apb): add link type, tag is Link

This commit is contained in:
əlemi 2024-06-19 17:56:05 +02:00
parent 9785b9856c
commit cf26b77fdf
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 6 additions and 1 deletions

View file

@ -18,6 +18,7 @@ crate::strenum! {
} }
pub trait Link : crate::Base { pub trait Link : crate::Base {
fn link_type(&self) -> Field<LinkType> { Err(FieldErr("type")) }
fn href(&self) -> &str; fn href(&self) -> &str;
fn rel(&self) -> Field<&str> { Err(FieldErr("rel")) } fn rel(&self) -> Field<&str> { Err(FieldErr("rel")) }
fn media_type(&self) -> Field<&str> { Err(FieldErr("mediaType")) } // also in obj fn media_type(&self) -> Field<&str> { Err(FieldErr("mediaType")) } // also in obj
@ -29,6 +30,7 @@ pub trait Link : crate::Base {
} }
pub trait LinkMut : crate::BaseMut { pub trait LinkMut : crate::BaseMut {
fn set_link_type(self, val: Option<LinkType>) -> Self;
fn set_href(self, href: &str) -> Self; fn set_href(self, href: &str) -> Self;
fn set_rel(self, val: 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_media_type(self, val: Option<&str>) -> Self; // also in obj
@ -56,6 +58,7 @@ impl Link for serde_json::Value {
} }
} }
crate::getter! { link_type -> type LinkType }
crate::getter! { rel -> &str } crate::getter! { rel -> &str }
crate::getter! { mediaType -> &str } crate::getter! { mediaType -> &str }
crate::getter! { name -> &str } crate::getter! { name -> &str }
@ -80,6 +83,7 @@ impl LinkMut for serde_json::Value {
self self
} }
crate::setter! { link_type -> type LinkType }
crate::setter! { rel -> &str } crate::setter! { rel -> &str }
crate::setter! { mediaType -> &str } crate::setter! { mediaType -> &str }
crate::setter! { name -> &str } crate::setter! { name -> &str }

View file

@ -92,7 +92,8 @@ pub trait Object : Base {
fn summary(&self) -> Field<&str> { Err(FieldErr("summary")) } fn summary(&self) -> Field<&str> { Err(FieldErr("summary")) }
/// One or more "tags" that have been associated with an objects. A tag can be any kind of Object /// 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 /// The key difference between attachment and tag is that the former implies association by inclusion, while the latter implies associated by reference
fn tag(&self) -> Node<Self::Object> { Node::Empty } // TODO technically this is an object? but spec says that it works my reference, idk
fn tag(&self) -> Node<Self::Link> { Node::Empty }
/// Identifies one or more links to representations of the object /// Identifies one or more links to representations of the object
fn url(&self) -> Node<Self::Link> { Node::Empty } fn url(&self) -> Node<Self::Link> { Node::Empty }
/// Identifies an entity considered to be part of the public primary audience of an Object /// Identifies an entity considered to be part of the public primary audience of an Object