pub struct CodecRegistry { /* private fields */ }Expand description
Registry for resolving codecs by stable id, file extension, or fallback.
Implementations§
Source§impl CodecRegistry
impl CodecRegistry
Sourcepub fn register(&mut self, codec: Arc<dyn Codec>, extensions: &[&str])
pub fn register(&mut self, codec: Arc<dyn Codec>, extensions: &[&str])
Register a codec and map the provided extensions to its id.
Sourcepub fn set_fallback(&mut self, codec: Arc<dyn Codec>)
pub fn set_fallback(&mut self, codec: Arc<dyn Codec>)
Register the fallback codec used when no extension-specific codec matches.
Sourcepub fn get(&self, codec_id: &str) -> Result<&Arc<dyn Codec>, PatchError>
pub fn get(&self, codec_id: &str) -> Result<&Arc<dyn Codec>, PatchError>
Get a codec by stable id.
Sourcepub fn get_by_extension(&self, ext: &str) -> Option<&Arc<dyn Codec>>
pub fn get_by_extension(&self, ext: &str) -> Option<&Arc<dyn Codec>>
Get a codec by file extension without the leading dot.
Sourcepub fn get_for_path(&self, path: &str) -> Option<&Arc<dyn Codec>>
pub fn get_for_path(&self, path: &str) -> Option<&Arc<dyn Codec>>
Get the best codec for a file path, falling back when configured.
Sourcepub fn default_registry() -> Self
pub fn default_registry() -> Self
Build the default registry with text, JSON, and binary codecs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CodecRegistry
impl !RefUnwindSafe for CodecRegistry
impl Send for CodecRegistry
impl Sync for CodecRegistry
impl Unpin for CodecRegistry
impl UnsafeUnpin for CodecRegistry
impl !UnwindSafe for CodecRegistry
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