pub struct ResourceOptions {
pub only: Vec<ResourceAction>,
pub except: Vec<ResourceAction>,
}Expand description
资源路由选项(only/except 过滤,对齐 ThinkPHP 6 Resource::only() / except())
Fields§
§only: Vec<ResourceAction>仅生成指定的动作(对齐 ->only([...]))
except: Vec<ResourceAction>排除指定的动作(对齐 ->except([...]))
Implementations§
Source§impl ResourceOptions
impl ResourceOptions
Sourcepub fn with_only(self, only: Vec<ResourceAction>) -> Self
pub fn with_only(self, only: Vec<ResourceAction>) -> Self
设置 only 过滤
Sourcepub fn with_except(self, except: Vec<ResourceAction>) -> Self
pub fn with_except(self, except: Vec<ResourceAction>) -> Self
设置 except 过滤
Sourcepub fn should_include(&self, action: ResourceAction) -> bool
pub fn should_include(&self, action: ResourceAction) -> bool
判断指定动作是否应该生成
对齐 ThinkPHP 6 Resource.php 第 106-109 行的过滤逻辑:
if (isset($option['only']) && !in_array($key, $option['only'])) continue;
if (isset($option['except']) && in_array($key, $option['except'])) continue;
Trait Implementations§
Source§impl Clone for ResourceOptions
impl Clone for ResourceOptions
Source§fn clone(&self) -> ResourceOptions
fn clone(&self) -> ResourceOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResourceOptions
impl Debug for ResourceOptions
Source§impl Default for ResourceOptions
impl Default for ResourceOptions
Source§fn default() -> ResourceOptions
fn default() -> ResourceOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ResourceOptions
impl RefUnwindSafe for ResourceOptions
impl Send for ResourceOptions
impl Sync for ResourceOptions
impl Unpin for ResourceOptions
impl UnsafeUnpin for ResourceOptions
impl UnwindSafe for ResourceOptions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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