pub struct CodecMetadata { /* private fields */ }Expand description
Metadata from a codec decode operation.
Captures everything needed for round-trip encoding: the content type, and a flexible key-value store for codec-specific data (e.g., BOM presence, original line ending style, encoding name).
§Examples
use reovim_driver_codec::{CodecMetadata, ContentType};
let mut metadata = CodecMetadata::new(ContentType::new("text/utf-8"));
metadata.set("bom", "true");
metadata.set("line_ending", "crlf");
assert_eq!(metadata.get("bom"), Some("true"));
assert_eq!(metadata.content_type().as_str(), "text/utf-8");Implementations§
Source§impl CodecMetadata
impl CodecMetadata
Sourcepub fn new(content_type: ContentType) -> Self
pub fn new(content_type: ContentType) -> Self
Create new metadata for the given content type.
Sourcepub const fn content_type(&self) -> &ContentType
pub const fn content_type(&self) -> &ContentType
Get the content type.
Sourcepub fn remove(&mut self, key: &str) -> Option<String>
pub fn remove(&mut self, key: &str) -> Option<String>
Remove a metadata value, returning it if present.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check if a metadata key exists.
Trait Implementations§
Source§impl Clone for CodecMetadata
impl Clone for CodecMetadata
Source§fn clone(&self) -> CodecMetadata
fn clone(&self) -> CodecMetadata
Returns a duplicate of the value. Read more
1.0.0 · 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 CodecMetadata
impl Debug for CodecMetadata
Source§impl PartialEq for CodecMetadata
impl PartialEq for CodecMetadata
impl Eq for CodecMetadata
Auto Trait Implementations§
impl Freeze for CodecMetadata
impl RefUnwindSafe for CodecMetadata
impl Send for CodecMetadata
impl Sync for CodecMetadata
impl Unpin for CodecMetadata
impl UnsafeUnpin for CodecMetadata
impl UnwindSafe for CodecMetadata
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