Skip to main content

ActionSpec

Struct ActionSpec 

Source
pub struct ActionSpec {
Show 16 fields pub name: ActionName, pub route: RouteSpec, pub params: Vec<ParamSpec>, pub calls: Vec<ActionRef>, pub display_name: String, pub description: String, pub permissions: Vec<String>, pub permission_mode: PermissionMode, pub is_public: bool, pub request_media_type: ActionMediaType, pub multipart: Option<MultipartSpec>, pub response_kind: ActionResponseKind, pub success_status: u16, pub tags: Vec<String>, pub input_schema: Value, pub output_schema: Value, /* private fields */
}
Expand description

Action 的定义期契约。

Fields§

§name: ActionName

Action 局部名称。

§route: RouteSpec

唯一传输路由。

§params: Vec<ParamSpec>

强类型参数定义。

§calls: Vec<ActionRef>

内部调用依赖。

§display_name: String

用户可见名称。

§description: String

业务说明。

§permissions: Vec<String>

Action 所需权限。

§permission_mode: PermissionMode

权限集合的匹配方式。

§is_public: bool

是否允许匿名访问。

§request_media_type: ActionMediaType

请求媒体类型。

§multipart: Option<MultipartSpec>

multipart 资源与类型限制;仅 multipart Action 可用。

§response_kind: ActionResponseKind

成功响应的静态类别,供调用方选择安全的展示方式。

§success_status: u16

成功响应状态码。

§tags: Vec<String>

OpenAPI/后台元数据标签。

§input_schema: Value

Handler Input 的构建期 JSON Schema。

§output_schema: Value

Handler Output 的构建期 JSON Schema。

Implementations§

Source§

impl ActionSpec

Source

pub fn new(name: ActionName, route: RouteSpec) -> Self

创建最小 Action 定义。

Source

pub fn display_name(self, display_name: impl Into<String>) -> Self

设置用户可见名称。

Source

pub fn description(self, description: impl Into<String>) -> Self

设置业务说明。

Source

pub fn permissions<I, S>(self, permissions: I, mode: PermissionMode) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

设置所需权限及匹配方式。

Source

pub fn public(self, is_public: bool) -> Self

设置是否允许匿名访问。

Source

pub fn multipart(self, multipart: MultipartSpec) -> Self

声明 Action 接受受限的 multipart/form-data 请求。

Source

pub fn response_kind(self, response_kind: ActionResponseKind) -> Self

声明成功响应的静态类别。

Source

pub fn success_status(self, success_status: u16) -> Self

设置成功响应 HTTP 状态码。

Source

pub fn tag(self, tag: impl Into<String>) -> Self

增加元数据标签。

Source

pub fn param(self, param: ParamSpec) -> Self

增加一个参数定义。

Source

pub fn params(self, params: Params) -> Self

使用一个 Params 集合替换当前参数定义。

Source

pub fn calls(self, action: ActionRef) -> Self

声明一个内部 Action 调用引用。

Trait Implementations§

Source§

impl Clone for ActionSpec

Source§

fn clone(&self) -> ActionSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActionSpec

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ActionSpec

Source§

impl From<&ActionSpec> for ActionDemoSchema

Source§

fn from(action: &ActionSpec) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ActionSpec

Source§

fn eq(&self, other: &ActionSpec) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ActionSpec

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more