pub struct KeyCache { /* private fields */ }Expand description
AIS 签名公钥缓存管理器
缓存 AIS Ed25519 verifying key,以 key_id 为索引。 用于 signaling 等服务在验证 AIdCredential 时按 key_id 查找对应公钥。
Implementations§
Source§impl KeyCache
impl KeyCache
Sourcepub async fn new<P: AsRef<Path>>(cache_db_file: P) -> Result<Self, AidError>
pub async fn new<P: AsRef<Path>>(cache_db_file: P) -> Result<Self, AidError>
创建新的密钥缓存实例并初始化 SQLite 表
Sourcepub async fn get_cached_key(
&self,
key_id: u32,
) -> Result<Option<(VerifyingKey, u64)>, AidError>
pub async fn get_cached_key( &self, key_id: u32, ) -> Result<Option<(VerifyingKey, u64)>, AidError>
从缓存中获取 Ed25519 verifying key
返回 (VerifyingKey, expires_at);若缓存不存在或已过期则返回 None。
Sourcepub async fn cache_key(
&self,
key_id: u32,
verifying_key: &VerifyingKey,
expires_at: u64,
) -> Result<(), AidError>
pub async fn cache_key( &self, key_id: u32, verifying_key: &VerifyingKey, expires_at: u64, ) -> Result<(), AidError>
将 Ed25519 verifying key 写入缓存
expires_at 为 Unix 秒时间戳,传 0 表示永不过期。
Sourcepub async fn cleanup_expired_keys(&self) -> Result<u32, AidError>
pub async fn cleanup_expired_keys(&self) -> Result<u32, AidError>
清理所有已过期的缓存条目
Sourcepub async fn get_cached_key_count(&self) -> Result<u32, AidError>
pub async fn get_cached_key_count(&self) -> Result<u32, AidError>
返回缓存中的条目总数(用于监控/调试)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for KeyCache
impl !UnwindSafe for KeyCache
impl Freeze for KeyCache
impl Send for KeyCache
impl Sync for KeyCache
impl Unpin for KeyCache
impl UnsafeUnpin for KeyCache
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request