Skip to main content

command

Attribute Macro command 

Source
#[command]
Expand description

함수를 rustra 명령으로 등록하는 속성 매크로입니다.

§지원 기능

  • 동기(fn) 및 비동기(async fn) 함수 지원
  • 0개 인자(fn ping() -> Result<()>) 및 1개 데이터 인자(fn add(input: Input) -> Result<Output>)
  • State<T> 의존성 자동 주입 (fn get(input: In, db: State<Db>) -> Result<Out>)
  • Rust doc comment(///)를 추출하여 메타데이터에 보존

§명령 이름 규칙

  • #[command]: 함수 이름에서 _command 접미사를 제거한 뒤 lowerCamelCase로 변환 (예: add_numbersaddNumbers)
  • #[command(name = "customName")]: 지정한 이름을 그대로 사용