pub struct Command<T, R, F, E>where
T: XyzArgs,
R: XyzSchema + Serialize,
F: Fn(&Ctx, &T) -> Result<R, E> + Send + Sync + 'static,
E: Error + Send + Sync + 'static,{ /* private fields */ }Expand description
Command 是一条命令的定义构造器。
Implementations§
Source§impl<T, R, F, E> Command<T, R, F, E>
impl<T, R, F, E> Command<T, R, F, E>
Sourcepub fn new(name: &str, handler: F) -> Self
pub fn new(name: &str, handler: F) -> Self
打开一条命令定义。name 必须匹配 ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$ (MCP tool 名兼容);检查在 entry() 执行,所以 define 本身不会失败。
Sourcepub fn description(self, s: impl Into<String>) -> Self
pub fn description(self, s: impl Into<String>) -> Self
更长的解释(完整帮助与工具文档展示)。
Trait Implementations§
Auto Trait Implementations§
impl<T, R, F, E> Freeze for Command<T, R, F, E>
impl<T, R, F, E> RefUnwindSafe for Command<T, R, F, E>
impl<T, R, F, E> Send for Command<T, R, F, E>
impl<T, R, F, E> Sync for Command<T, R, F, E>
impl<T, R, F, E> Unpin for Command<T, R, F, E>
impl<T, R, F, E> UnsafeUnpin for Command<T, R, F, E>
impl<T, R, F, E> UnwindSafe for Command<T, R, F, E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more