mirror of
https://git.asonix.dog/asonix/activitystreams.git
synced 2024-11-22 11:51:00 +00:00
Optionally typetag, update docs
This commit is contained in:
parent
62c8d245ff
commit
2c0658d77e
2 changed files with 21 additions and 4 deletions
|
@ -142,14 +142,22 @@ pub fn ref_derive(input: TokenStream) -> TokenStream {
|
||||||
let name = name.clone();
|
let name = name.clone();
|
||||||
let ext_trait = Ident::new(&format!("{}Ext", object), name.span());
|
let ext_trait = Ident::new(&format!("{}Ext", object), name.span());
|
||||||
|
|
||||||
|
let tt = if object.to_string() == "Object" || object.to_string() == "Link" {
|
||||||
|
quote! {
|
||||||
|
#[typetag::serde]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
quote! {}
|
||||||
|
};
|
||||||
|
|
||||||
let activity_impls = quote! {
|
let activity_impls = quote! {
|
||||||
#[typetag::serde]
|
#tt
|
||||||
impl #object for #name {
|
impl #object for #name {
|
||||||
fn as_any(&self) -> &std::any::Any {
|
fn as_any(&self) -> &dyn std::any::Any {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_mut(&self) -> &mut std::any::Any {
|
fn as_any_mut(&self) -> &mut dyn std::any::Any {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
//! use activitystreams_traits::Object;
|
//! use activitystreams_traits::Object;
|
||||||
//! use activitystreams_types::object::properties::ObjectProperties;
|
//! use activitystreams_types::object::properties::ObjectProperties;
|
||||||
//! use serde_derive::{Deserialize, Serialize};
|
//! use serde_derive::{Deserialize, Serialize};
|
||||||
|
//! use std::any::Any;
|
||||||
//!
|
//!
|
||||||
//! #[derive(Clone, Debug, Serialize, Deserialize)]
|
//! #[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
//! #[serde(rename_all = "camelCase")]
|
//! #[serde(rename_all = "camelCase")]
|
||||||
|
@ -39,7 +40,15 @@
|
||||||
//! pub object_properties: ObjectProperties,
|
//! pub object_properties: ObjectProperties,
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! impl Object for MyObject {}
|
//! impl Object for MyObject {
|
||||||
|
//! fn as_any(&self) -> &dyn Any {
|
||||||
|
//! self
|
||||||
|
//! }
|
||||||
|
//!
|
||||||
|
//! fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||||
|
//! self
|
||||||
|
//! }
|
||||||
|
//! }
|
||||||
//! #
|
//! #
|
||||||
//! # fn main() {}
|
//! # fn main() {}
|
||||||
//! ```
|
//! ```
|
||||||
|
|
Loading…
Reference in a new issue