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.

§Manifest

Reads act.toml from the crate root for component metadata and capabilities. If act.toml is absent, all metadata comes from Cargo.toml.

Resolution order: attribute > act.toml > Cargo.toml.

§Attributes

  • manifest = "..." — Path to manifest file (default: "act.toml")
  • name = "..." — Override component name
  • version = "..." — Override component version
  • description = "..." — Override component description
  • default_language = "..." — Override BCP 47 language tag

§Examples

// Reads act.toml, falls back to Cargo.toml:
#[act_component]
mod component {
    use super::*;

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

// Feature-flag variant with attribute overrides:
#[cfg_attr(not(feature = "vec"), act_component)]
#[cfg_attr(feature = "vec", act_component(
    name = "sqlite-vec",
    description = "SQLite with vector search"
))]
mod component { /* ... */ }