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 new() -> ResourceOptions
pub fn new() -> ResourceOptions
创建空选项(生成全部 7 条路由)
Sourcepub fn with_only(self, only: Vec<ResourceAction>) -> ResourceOptions
pub fn with_only(self, only: Vec<ResourceAction>) -> ResourceOptions
设置 only 过滤
Sourcepub fn with_except(self, except: Vec<ResourceAction>) -> ResourceOptions
pub fn with_except(self, except: Vec<ResourceAction>) -> ResourceOptions
设置 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.