pub struct EncryptedFileCredentialStore { /* private fields */ }Expand description
加密文件凭据存储。
bot 信息与 Bearer token 共存于目录内单一加密文件 credentials.enc
(AES-256-GCM,密钥存 .encryption_key 文件 + 系统 keyring 回退);
bot 与 token 均空时不落盘(删除既有文件,避免残留空凭据)。
Implementations§
Source§impl EncryptedFileCredentialStore
impl EncryptedFileCredentialStore
Sourcepub fn new(dir: impl Into<PathBuf>) -> EncryptedFileCredentialStore
pub fn new(dir: impl Into<PathBuf>) -> EncryptedFileCredentialStore
在 dir 下创建存储(keyring 默认启用)。
Sourcepub fn keyring_enabled(&self) -> bool
pub fn keyring_enabled(&self) -> bool
keyring 回退是否启用。
Sourcepub fn with_keyring(self, enabled: bool) -> EncryptedFileCredentialStore
pub fn with_keyring(self, enabled: bool) -> EncryptedFileCredentialStore
是否使用系统 keyring 持久化加密密钥(默认启用)。
容器等无 keyring 环境可关闭;关闭后密钥仅存 .encryption_key 文件。
Sourcepub fn credentials_path(&self) -> PathBuf
pub fn credentials_path(&self) -> PathBuf
加密凭据文件路径(<dir>/credentials.enc)。
Sourcepub fn legacy_paths(&self) -> [PathBuf; 2]
pub fn legacy_paths(&self) -> [PathBuf; 2]
旧版独立凭据文件(bot.enc / token.enc)路径。
凭据统一存放于 credentials.enc;旧文件不主动清理——仅由
try_migrate_legacy_credentials 在迁移时读取。
Sourcepub fn encryption_key_path(&self) -> PathBuf
pub fn encryption_key_path(&self) -> PathBuf
加密密钥文件路径(<dir>/.encryption_key)。
Sourcepub fn generate_key(&self) -> [u8; 32]
pub fn generate_key(&self) -> [u8; 32]
生成新的随机加密密钥。
Trait Implementations§
Source§impl Clone for EncryptedFileCredentialStore
impl Clone for EncryptedFileCredentialStore
Source§fn clone(&self) -> EncryptedFileCredentialStore
fn clone(&self) -> EncryptedFileCredentialStore
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 moreAuto Trait Implementations§
impl Freeze for EncryptedFileCredentialStore
impl RefUnwindSafe for EncryptedFileCredentialStore
impl Send for EncryptedFileCredentialStore
impl Sync for EncryptedFileCredentialStore
impl Unpin for EncryptedFileCredentialStore
impl UnsafeUnpin for EncryptedFileCredentialStore
impl UnwindSafe for EncryptedFileCredentialStore
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