Skip to main content

act_component

Attribute Macro act_component 

Source
#[act_component]
Expand description

Attribute macro for ACT component modules.

Transforms a module containing #[act_tool] functions into a complete WIT component implementation with wit_bindgen::generate!(), export!(), and a Guest trait implementation.

§Attributes

All attributes are optional — defaults are taken from Cargo.toml:

  • name = "..." — Component name (default: CARGO_PKG_NAME)
  • version = "..." — Component version (default: CARGO_PKG_VERSION)
  • description = "..." — Component description (default: CARGO_PKG_DESCRIPTION)
  • default_language = "..." — BCP 47 language tag (default: "en")

§Examples

// All fields from Cargo.toml:
#[act_component]
mod component {
    use super::*;

    #[act_tool(description = "Say hello")]
    fn greet(name: String) -> ActResult<String> {
        Ok(format!("Hello, {name}!"))
    }
}

// Override just the name:
#[act_component(name = "custom-name")]
mod component {
    // ...
}