pub struct RouteRegistry {
pub attribute_routes: Vec<RouteRule>,
pub config_routes: Vec<RouteRule>,
pub convention_routes: Vec<ConventionRoute>,
}Expand description
三层路由注册表
收集三层路由的元数据,提供统一的查询和冲突检测接口。
§注意
实际将路由注册到 axum::Router 需要 ControllerRegistry(在 controller_registry 模块实现)。
本模块仅提供元数据管理和冲突检测。
Fields§
§attribute_routes: Vec<RouteRule>Layer 1 - 属性宏路由
config_routes: Vec<RouteRule>Layer 2 - 配置式路由
convention_routes: Vec<ConventionRoute>Layer 3 - 约定式路由
Implementations§
Source§impl RouteRegistry
impl RouteRegistry
Sourcepub fn add_attribute_route(&mut self, rule: RouteRule) -> &mut Self
pub fn add_attribute_route(&mut self, rule: RouteRule) -> &mut Self
添加属性宏路由
Sourcepub fn add_attribute_routes(
&mut self,
rules: impl IntoIterator<Item = RouteRule>,
) -> &mut Self
pub fn add_attribute_routes( &mut self, rules: impl IntoIterator<Item = RouteRule>, ) -> &mut Self
批量添加属性宏路由
Sourcepub fn add_config_routes(&mut self, config: &RouteConfig) -> &mut Self
pub fn add_config_routes(&mut self, config: &RouteConfig) -> &mut Self
添加配置式路由
Sourcepub fn add_convention_route(&mut self, route: ConventionRoute) -> &mut Self
pub fn add_convention_route(&mut self, route: ConventionRoute) -> &mut Self
添加约定式路由
Sourcepub fn convention_as_rules(&self) -> Vec<RouteRule>
pub fn convention_as_rules(&self) -> Vec<RouteRule>
转换约定式路由为 RouteRule 列表
约定式路由的 handler 字段为 Controller@action 格式。
Sourcepub fn merged_rules(&self) -> Vec<RouteRule>
pub fn merged_rules(&self) -> Vec<RouteRule>
合并所有三层的路由规则(按优先级:attribute > config > convention)
冲突时优先级高的覆盖低的,返回最终路由列表。
Sourcepub fn attribute_conflicts(&self) -> Vec<(RouteRule, RouteRule)>
pub fn attribute_conflicts(&self) -> Vec<(RouteRule, RouteRule)>
检测属性宏层内部的冲突
Sourcepub fn config_conflicts(&self) -> Vec<(RouteRule, RouteRule)>
pub fn config_conflicts(&self) -> Vec<(RouteRule, RouteRule)>
检测配置式层内部的冲突
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
路由总数
Trait Implementations§
Source§impl Clone for RouteRegistry
impl Clone for RouteRegistry
Source§fn clone(&self) -> RouteRegistry
fn clone(&self) -> RouteRegistry
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 RouteRegistry
impl Debug for RouteRegistry
Source§impl Default for RouteRegistry
impl Default for RouteRegistry
Source§fn default() -> RouteRegistry
fn default() -> RouteRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RouteRegistry
impl RefUnwindSafe for RouteRegistry
impl Send for RouteRegistry
impl Sync for RouteRegistry
impl Unpin for RouteRegistry
impl UnsafeUnpin for RouteRegistry
impl UnwindSafe for RouteRegistry
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.