diff --git a/Cargo.lock b/Cargo.lock index 3da8fbb8..c1ec1715 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2073,8 +2073,11 @@ dependencies = [ name = "ceramic-actor-macros" version = "0.47.3" dependencies = [ + "async-trait", + "ceramic-actor", "quote", "syn 2.0.90", + "tokio", ] [[package]] diff --git a/actor-macros/Cargo.toml b/actor-macros/Cargo.toml index c4cda44c..1bcc1777 100644 --- a/actor-macros/Cargo.toml +++ b/actor-macros/Cargo.toml @@ -12,3 +12,8 @@ proc-macro = true [dependencies] syn = "2.0" quote = "1.0" + +[dev-dependencies] +ceramic-actor.workspace = true +async-trait.workspace = true +tokio.workspace = true diff --git a/actor-macros/src/lib.rs b/actor-macros/src/lib.rs index 1434a1b7..14eeec6c 100644 --- a/actor-macros/src/lib.rs +++ b/actor-macros/src/lib.rs @@ -17,9 +17,31 @@ use syn::{parse_macro_input, Attribute, DeriveInput, GenericParam, Lit}; /// /// # Example /// ``` +/// # use ceramic_actor::{Handler, Message}; +/// use ceramic_actor::{Actor, actor_envelope}; +/// /// #[derive(Actor)] /// #[actor(envelope = "PlayerEnv", handle = "PlayerH", actor_trait = "PlayerI")] /// pub struct Player { } +/// +/// actor_envelope!{ +/// PlayerEnv, +/// PlayerI, +/// Score => ScoreMessage, +/// } +/// +/// # #[async_trait::async_trait] +/// # impl Handler for Player { +/// # async fn handle(&mut self, message: ScoreMessage) -> ::Result { +/// # todo!() +/// # } +/// # } +/// +/// # #[derive(Debug)] +/// # struct ScoreMessage { } +/// # impl Message for ScoreMessage { +/// # type Result = (); +/// # } /// ``` #[proc_macro_derive(Actor, attributes(actor))] pub fn actor(item: TokenStream) -> TokenStream { diff --git a/actor/src/macros.rs b/actor/src/macros.rs index 5fb6145f..fba597f0 100644 --- a/actor/src/macros.rs +++ b/actor/src/macros.rs @@ -77,7 +77,7 @@ macro_rules! actor_envelope { actor.handle(m), traced.span, ).await).is_err() { - ::tracing::warn!("failed to send message to actor"); + $crate::tracing::warn!("failed to send message to actor"); } } )*