pub struct Registry { /* private fields */ }Expand description
ActionRef 到稳定运行时 slot 的不可变映射。
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn resolve(&self, action: &ActionRef) -> Option<ActionHandle>
pub fn resolve(&self, action: &ActionRef) -> Option<ActionHandle>
解析构建期已验证的 Action 引用。
Sourcepub fn resolve_typed<I, O>(
&self,
action: &ActionRef,
) -> Result<TypedActionHandle<I, O>, BaseError>
pub fn resolve_typed<I, O>( &self, action: &ActionRef, ) -> Result<TypedActionHandle<I, O>, BaseError>
解析并校验强类型内部调用句柄。
Sourcepub fn handler(&self, handle: ActionHandle) -> Result<&dyn DynAction, BaseError>
pub fn handler(&self, handle: ActionHandle) -> Result<&dyn DynAction, BaseError>
返回预绑定 Handler;无效 handle 稳定返回 ActionNotFound。
Sourcepub async fn dispatch(
&self,
handle: ActionHandle,
context: ActionContext,
) -> Result<ApiResponse, BaseError>
pub async fn dispatch( &self, handle: ActionHandle, context: ActionContext, ) -> Result<ApiResponse, BaseError>
通过构建期 handle 执行唯一预绑定 Handler。
Sourcepub async fn call<I, O>(
&self,
handle: TypedActionHandle<I, O>,
context: ActionContext,
input: I,
) -> Result<O, BaseError>
pub async fn call<I, O>( &self, handle: TypedActionHandle<I, O>, context: ActionContext, input: I, ) -> Result<O, BaseError>
使用强类型输入直接调用预解析 Action;不发生 JSON 序列化或名称查找。
§约束范围(重要)
内部调用不经过中间件链:StepUpMiddleware、租户解析等中间件仅在
Registry::dispatch 路径执行,本方法(以及 Plugins::api_run)只做
权限校验后直接调用 Handler。敏感 Action 的 step-up 因此不约束内部调用;
调用方是受信代码,如需重认证必须自行编排 StepUpManager。该语义由
internal_call_bypasses_step_up_middleware_by_design 测试锁定。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Registry
impl !UnwindSafe for Registry
impl Forget for Registry
impl Freeze for Registry
impl Move for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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