Skip to content

Enhancement: Write "async_handler" proc_macro #28

Description

@ZialeHub

Added to pulsync-derive as a #[proc_macro_attribute]. It rewrites a plain async fn run into the dyn-compatible Pin<Box> form:

  // User writes:
  #[async_handler]
  impl AsyncTaskHandler for MyTask {
      async fn run(&self) {
          do_work().await;
      }
  }

  // Macro emits:
  impl AsyncTaskHandler for MyTask {
      fn run(&self) -> Pin<Box<dyn Future<Output = ()> + Send + '_ + Sync>> {
          Box::pin(async move { do_work().await; })
      }
  }

This reduce the complex type return for the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions