pub struct CompressionRegistry { /* private fields */ }Expand description
压缩器注册表
管理压缩器的注册和查找
Implementations§
Source§impl CompressionRegistry
impl CompressionRegistry
Sourcepub fn register_defaults(&self)
pub fn register_defaults(&self)
注册内置压缩器
Sourcepub fn register(&self, name: &str, compressor: Arc<dyn Compressor>)
pub fn register(&self, name: &str, compressor: Arc<dyn Compressor>)
注册压缩器
§参数
name: 压缩器名称(用于查找)compressor: 压缩器实例
§示例
use flare_core::common::compression::{CompressionRegistry, Compressor};
use std::sync::Arc;
struct MyCompressor;
impl Compressor for MyCompressor { /* ... */ }
let registry = CompressionRegistry::new();
registry.register("my_custom", Arc::new(MyCompressor));Sourcepub fn find_by_algorithm(
&self,
algorithm: CompressionAlgorithm,
) -> Option<Arc<dyn Compressor>>
pub fn find_by_algorithm( &self, algorithm: CompressionAlgorithm, ) -> Option<Arc<dyn Compressor>>
根据算法类型查找压缩器
Sourcepub fn is_registered(&self, name: &str) -> bool
pub fn is_registered(&self, name: &str) -> bool
Sourcepub fn auto_detect(&self, data: &[u8]) -> Option<Arc<dyn Compressor>>
pub fn auto_detect(&self, data: &[u8]) -> Option<Arc<dyn Compressor>>
尝试自动检测压缩算法
遍历所有注册的压缩器,使用 can_detect 方法检测
Sourcepub fn global() -> &'static CompressionRegistry
pub fn global() -> &'static CompressionRegistry
获取全局注册表实例
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CompressionRegistry
impl RefUnwindSafe for CompressionRegistry
impl Send for CompressionRegistry
impl Sync for CompressionRegistry
impl Unpin for CompressionRegistry
impl UnsafeUnpin for CompressionRegistry
impl UnwindSafe for CompressionRegistry
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