feat(apb): .value() but its not really from did-core

This commit is contained in:
əlemi 2024-07-15 21:54:19 +02:00
parent 1d01a1cbf9
commit bad86f5bcf
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -127,6 +127,9 @@ pub trait Object : Base {
fn as_actor(&self) -> Result<&Self::Actor, FieldErr> { Err(FieldErr("type")) }
fn as_collection(&self) -> Result<&Self::Collection, FieldErr> { Err(FieldErr("type")) }
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")) }
}
pub trait ObjectMut : BaseMut {
@ -176,6 +179,9 @@ pub trait ObjectMut : BaseMut {
#[cfg(feature = "ostatus")]
fn set_conversation(self, val: Node<Self::Object>) -> Self;
#[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?!
fn set_value(self, val: Option<&str>) -> Self;
}
#[cfg(feature = "unstructured")]
@ -228,6 +234,9 @@ impl Object for serde_json::Value {
#[cfg(feature = "ostatus")]
crate::getter! { conversation -> node <Self as Object>::Object }
#[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?!
crate::getter! { value -> &str }
fn as_activity(&self) -> Result<&Self::Activity, FieldErr> {
match self.object_type()? {
ObjectType::Activity(_) => Ok(self),
@ -305,4 +314,7 @@ impl ObjectMut for serde_json::Value {
#[cfg(feature = "ostatus")]
crate::setter! { conversation -> node <Self as Object>::Object }
#[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?!
crate::setter! { value -> &str }
}