Skip to main content

task

Attribute Macro task 

Source
#[task]
Expand description

Define a trackable task inside an entrypoint.

Wraps an async function so that it carries a task name for tracing and streaming identification. The original function body is moved into a private {name}_impl helper and a public wrapper delegates to it.

§Attributes

  • name = "..." — override the task name (defaults to the function name)

§Example

use synaptic_macros::task;
use synaptic_core::SynapticError;

#[task]
async fn fetch_weather(city: String) -> Result<String, SynapticError> {
    Ok(format!("Sunny in {}", city))
}

// `fetch_weather` can be called directly — it forwards to `fetch_weather_impl`
let result = fetch_weather("Paris".into()).await;