pub struct Tools { /* private fields */ }Expand description
构建完成后冻结的应用资源。
Implementations§
Source§impl Tools
impl Tools
Sourcepub fn state(&self) -> ToolsState
pub fn state(&self) -> ToolsState
返回当前生命周期状态。
Sourcepub fn database(&self) -> Result<&AnyDatabase, BaseError>
pub fn database(&self) -> Result<&AnyDatabase, BaseError>
获取运行时数据库后端;未配置或生命周期已结束时失败。
Sourcepub fn mysql(&self) -> Result<&Database, BaseError>
pub fn mysql(&self) -> Result<&Database, BaseError>
获取 MySQL 连接池;未配置 MySQL 后端或生命周期已结束时失败。
当运行期配置的是 PostgreSQL 后端时同样返回 BaseError::DatabaseNotInitialized,
避免把 PG 连接池误当作 MySQL 使用。
Sourcepub fn pool_status(&self) -> Option<PoolStatus>
pub fn pool_status(&self) -> Option<PoolStatus>
返回当前数据库连接池状态快照;未配置数据库时为 None。
不检查生命周期状态,便于关闭后继续观察连接池回收情况。
Sourcepub fn cache(&self) -> Result<&RedisClient, BaseError>
pub fn cache(&self) -> Result<&RedisClient, BaseError>
获取 Redis 客户端;未配置或生命周期已结束时失败。
Sourcepub fn token(&self) -> Result<&TokenManager, BaseError>
pub fn token(&self) -> Result<&TokenManager, BaseError>
获取 Token 管理器;未配置或生命周期已结束时失败。
Sourcepub fn http(&self) -> Result<&HttpClient, BaseError>
pub fn http(&self) -> Result<&HttpClient, BaseError>
获取 HTTP 客户端;未配置或生命周期已结束时失败。
reqwest 客户端无需显式关闭,故该槽位不参与 close/health_check 流程。
Sourcepub fn regex_cache(&self) -> &RegexCache
pub fn regex_cache(&self) -> &RegexCache
获取共享的有界正则缓存。
缓存为冻结的不可变资源,无需参与 close/health_check 流程;始终可用。
Sourcepub async fn health_check(&self) -> ToolsHealth
pub async fn health_check(&self) -> ToolsHealth
检查所有已配置核心资源并返回稳定快照。
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Tools
impl !RefUnwindSafe for Tools
impl !UnwindSafe for Tools
impl Forget for Tools
impl Move for Tools
impl Send for Tools
impl Sync for Tools
impl Unpin for Tools
impl UnsafeUnpin for Tools
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
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