pub enum EncryptionAlgorithm {
None,
Aes256Gcm,
Custom(String),
}Expand description
加密算法类型枚举
支持内置算法和自定义算法扩展
Variants§
None
不使用加密
Aes256Gcm
AES-256-GCM 加密
Custom(String)
自定义加密算法(通过字符串标识符)
使用此变体可以注册和使用自定义加密算法
自定义算法必须通过 EncryptionUtil::register_custom 注册
§示例
use flare_core::common::encryption::{EncryptionAlgorithm, EncryptionUtil, Encryptor};
use std::sync::Arc;
// 注册自定义加密器
struct MyCustomEncryptor;
impl Encryptor for MyCustomEncryptor { /* ... */ }
EncryptionUtil::register_custom(Arc::new(MyCustomEncryptor));
// 使用自定义算法
let algo = EncryptionAlgorithm::Custom("my_custom".to_string());Implementations§
Source§impl EncryptionAlgorithm
impl EncryptionAlgorithm
Sourcepub fn from_str(s: &str) -> Option<Self>
pub fn from_str(s: &str) -> Option<Self>
从字符串转换为加密算法
如果字符串匹配内置算法,返回对应的枚举值
否则返回 Custom(String) 变体
§示例
use flare_core::common::encryption::EncryptionAlgorithm;
assert_eq!(EncryptionAlgorithm::from_str("none"), Some(EncryptionAlgorithm::None));
assert_eq!(EncryptionAlgorithm::from_str("aes256gcm"), Some(EncryptionAlgorithm::Aes256Gcm));
assert_eq!(
EncryptionAlgorithm::from_str("my_custom"),
Some(EncryptionAlgorithm::Custom("my_custom".to_string()))
);Sourcepub fn as_str(&self) -> String
pub fn as_str(&self) -> String
转换为字符串标识符
返回算法的字符串表示,可用于注册表查找
§示例
use flare_core::common::encryption::EncryptionAlgorithm;
assert_eq!(EncryptionAlgorithm::None.as_str(), "none");
assert_eq!(EncryptionAlgorithm::Aes256Gcm.as_str(), "aes256gcm");
assert_eq!(EncryptionAlgorithm::Custom("my_custom".to_string()).as_str(), "my_custom");Sourcepub fn custom_name(&self) -> Option<&str>
pub fn custom_name(&self) -> Option<&str>
获取自定义算法名称(如果是自定义算法)
Trait Implementations§
Source§impl Clone for EncryptionAlgorithm
impl Clone for EncryptionAlgorithm
Source§fn clone(&self) -> EncryptionAlgorithm
fn clone(&self) -> EncryptionAlgorithm
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 EncryptionAlgorithm
impl Debug for EncryptionAlgorithm
Source§impl<'de> Deserialize<'de> for EncryptionAlgorithm
impl<'de> Deserialize<'de> for EncryptionAlgorithm
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for EncryptionAlgorithm
Source§impl Hash for EncryptionAlgorithm
impl Hash for EncryptionAlgorithm
Source§impl PartialEq for EncryptionAlgorithm
impl PartialEq for EncryptionAlgorithm
Source§fn eq(&self, other: &EncryptionAlgorithm) -> bool
fn eq(&self, other: &EncryptionAlgorithm) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for EncryptionAlgorithm
impl Serialize for EncryptionAlgorithm
impl StructuralPartialEq for EncryptionAlgorithm
Auto Trait Implementations§
impl Freeze for EncryptionAlgorithm
impl RefUnwindSafe for EncryptionAlgorithm
impl Send for EncryptionAlgorithm
impl Sync for EncryptionAlgorithm
impl Unpin for EncryptionAlgorithm
impl UnsafeUnpin for EncryptionAlgorithm
impl UnwindSafe for EncryptionAlgorithm
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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