Trait dicom_encoding::encode::BasicEncode
source · pub trait BasicEncode {
// Required methods
fn endianness(&self) -> Endianness;
fn encode_us<W>(&self, to: W, value: u16) -> Result<()>
where W: Write;
fn encode_ul<W>(&self, to: W, value: u32) -> Result<()>
where W: Write;
fn encode_uv<W>(&self, to: W, value: u64) -> Result<()>
where W: Write;
fn encode_ss<W>(&self, to: W, value: i16) -> Result<()>
where W: Write;
fn encode_sl<W>(&self, to: W, value: i32) -> Result<()>
where W: Write;
fn encode_sv<W>(&self, to: W, value: i64) -> Result<()>
where W: Write;
fn encode_fl<W>(&self, to: W, value: f32) -> Result<()>
where W: Write;
fn encode_fd<W>(&self, to: W, value: f64) -> Result<()>
where W: Write;
// Provided methods
fn with_encoder<T, F1, F2>(&self, f_le: F1, f_be: F2) -> T
where F1: FnOnce(LittleEndianBasicEncoder) -> T,
F2: FnOnce(BigEndianBasicEncoder) -> T { ... }
fn encode_primitive<W>(
&self,
to: W,
value: &PrimitiveValue
) -> Result<usize>
where W: Write { ... }
}
Expand description
Type trait for an encoder of basic data properties.
Unlike Encode
(and similar to BasicDecode
), this trait is not object
safe because it’s better to just provide a dynamic implementation.
Required Methods§
sourcefn endianness(&self) -> Endianness
fn endianness(&self) -> Endianness
Retrieve the encoder’s endianness.
sourcefn encode_us<W>(&self, to: W, value: u16) -> Result<()>where
W: Write,
fn encode_us<W>(&self, to: W, value: u16) -> Result<()>where
W: Write,
Encode an unsigned short value to the given writer.
sourcefn encode_ul<W>(&self, to: W, value: u32) -> Result<()>where
W: Write,
fn encode_ul<W>(&self, to: W, value: u32) -> Result<()>where
W: Write,
Encode an unsigned long value to the given writer.
sourcefn encode_uv<W>(&self, to: W, value: u64) -> Result<()>where
W: Write,
fn encode_uv<W>(&self, to: W, value: u64) -> Result<()>where
W: Write,
Encode an unsigned very long value to the given writer.
sourcefn encode_ss<W>(&self, to: W, value: i16) -> Result<()>where
W: Write,
fn encode_ss<W>(&self, to: W, value: i16) -> Result<()>where
W: Write,
Encode a signed short value to the given writer.
sourcefn encode_sl<W>(&self, to: W, value: i32) -> Result<()>where
W: Write,
fn encode_sl<W>(&self, to: W, value: i32) -> Result<()>where
W: Write,
Encode a signed long value to the given writer.
sourcefn encode_sv<W>(&self, to: W, value: i64) -> Result<()>where
W: Write,
fn encode_sv<W>(&self, to: W, value: i64) -> Result<()>where
W: Write,
Encode a signed very long value to the given writer.
Provided Methods§
sourcefn with_encoder<T, F1, F2>(&self, f_le: F1, f_be: F2) -> T
fn with_encoder<T, F1, F2>(&self, f_le: F1, f_be: F2) -> T
If this encoder is in Little Endian, evaluate the first function. Otherwise, evaluate the second one.
sourcefn encode_primitive<W>(&self, to: W, value: &PrimitiveValue) -> Result<usize>where
W: Write,
fn encode_primitive<W>(&self, to: W, value: &PrimitiveValue) -> Result<usize>where
W: Write,
Encode a primitive value to the given writer. The default implementation delegates to the other value encoding methods.
Object Safety§
This trait is not object safe.