Skip to main content

ResourceAction

Enum ResourceAction 

Source
pub enum ResourceAction {
    Index,
    Create,
    Edit,
    Read,
    Save,
    Update,
    Delete,
}
Expand description

RESTful 动作枚举(对齐 ThinkPHP 6 $rest 默认数组的 7 个键)

Variants§

§

Index

列表页(GET,URL 后缀 ''

§

Create

新建表单页(GET,URL 后缀 /create

§

Edit

编辑表单页(GET,URL 后缀 /<id>/edit

§

Read

单个资源详情(GET,URL 后缀 /<id>

§

Save

新建保存(POST,URL 后缀 ''

§

Update

更新(PUT,URL 后缀 /<id>

§

Delete

删除(DELETE,URL 后缀 /<id>

Implementations§

Source§

impl ResourceAction

Source

pub fn as_str(&self) -> &'static str

返回动作名称(对齐 ThinkPHP 6 $rest 数组的键名)

Source

pub fn http_method(&self) -> HttpMethod

返回对应的 HTTP 方法

Source

pub fn url_suffix(&self) -> &'static str

返回 URL 后缀(对齐 ThinkPHP 6 $rest 数组的第二元素)

Source

pub fn controller_method(&self) -> &'static str

返回控制器方法名(对齐 ThinkPHP 6 $rest 数组的第三元素)

Source

pub fn all() -> &'static [ResourceAction]

返回全部 7 个动作(按 ThinkPHP 6 $rest 数组顺序)

Source

pub fn parse_name(name: &str) -> Option<ResourceAction>

从字符串解析动作名(便捷方法,返回 Option)

注:对齐 std::str::FromStr trait 的语义,但保留 Option 返回类型以便测试使用。

Trait Implementations§

Source§

impl Clone for ResourceAction

Source§

fn clone(&self) -> ResourceAction

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 Copy for ResourceAction

Source§

impl Debug for ResourceAction

Source§

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

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

impl Eq for ResourceAction

Source§

impl FromStr for ResourceAction

实现 std::str::FromStr trait(对齐 Rust 标准库约定)

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for ResourceAction

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ResourceAction

Source§

fn eq(&self, other: &ResourceAction) -> 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 ResourceAction

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.