Trait dicom_encoding::text::TextCodec

source ·
pub trait TextCodec {
    // Required methods
    fn name(&self) -> Cow<'static, str>;
    fn decode(&self, text: &[u8]) -> Result<String, DecodeTextError>;
    fn encode(&self, text: &str) -> Result<Vec<u8>, EncodeTextError>;
}
Expand description

A holder of encoding and decoding mechanisms for text in DICOM content, which according to the standard, depends on the specific character set.

Required Methods§

source

fn name(&self) -> Cow<'static, str>

Obtain the defined term (unique name) of the text encoding, which may be used as the value of a Specific Character Set (0008, 0005) element to refer to this codec.

Should contain no leading or trailing spaces. This method may be useful for testing purposes, considering that TextCodec is often used as a trait object.

source

fn decode(&self, text: &[u8]) -> Result<String, DecodeTextError>

Decode the given byte buffer as a single string. The resulting string may contain backslash characters (’') to delimit individual values, and should be split later on if required.

source

fn encode(&self, text: &str) -> Result<Vec<u8>, EncodeTextError>

Encode a text value into a byte vector. The input string can feature multiple text values by using the backslash character (’') as the value delimiter.

Implementations on Foreign Types§

source§

impl<'a, T> TextCodec for &'a T
where T: TextCodec + ?Sized,

source§

fn name(&self) -> Cow<'static, str>

source§

fn decode(&self, text: &[u8]) -> Result<String, DecodeTextError>

source§

fn encode(&self, text: &str) -> Result<Vec<u8>, EncodeTextError>

source§

impl<T> TextCodec for Box<T>
where T: TextCodec + ?Sized,

source§

fn name(&self) -> Cow<'static, str>

source§

fn decode(&self, text: &[u8]) -> Result<String, DecodeTextError>

source§

fn encode(&self, text: &str) -> Result<Vec<u8>, EncodeTextError>

Implementors§