dicom_parser::stateful::encode

Struct StatefulEncoder

Source
pub struct StatefulEncoder<W, E, T = SpecificCharacterSet> { /* private fields */ }
Expand description

Also called a printer, this encoder type provides a stateful mid-level abstraction for writing DICOM content. Unlike Encode, the stateful encoder knows how to write text values and keeps track of how many bytes were written. W is the write target, E is the encoder, and T is the text codec.

Implementations§

Source§

impl<W, E, T> StatefulEncoder<W, E, T>

Source

pub fn new(to: W, encoder: E, text: T) -> Self

Source§

impl<'s> StatefulEncoder<Box<dyn Write + 's>, Box<dyn EncodeTo<dyn Write> + 's>>

Source

pub fn from_transfer_syntax( to: Box<dyn Write + 's>, ts: TransferSyntax, charset: SpecificCharacterSet, ) -> Result<Self>

Source§

impl<W, E> StatefulEncoder<W, E>
where W: Write, E: EncodeTo<W>,

Source

pub fn encode_element_header(&mut self, de: DataElementHeader) -> Result<()>

Encode and write a data element header.

Source

pub fn encode_item_header(&mut self, len: u32) -> Result<()>

Encode and write an item header, where len is the specified length of the item (can be 0xFFFF_FFFF for undefined length).

Source

pub fn encode_item_delimiter(&mut self) -> Result<()>

Encode and write an item delimiter.

Source

pub fn encode_sequence_delimiter(&mut self) -> Result<()>

Encode and write a sequence delimiter.

Source

pub fn write_raw_bytes(&mut self, bytes: &[u8]) -> Result<()>

Write the given bytes directly to the inner writer.

Note that this method (unlike write_bytes) does not perform any additional padding.

Source

pub fn write_bytes(&mut self, bytes: &[u8]) -> Result<()>

Write a primitive DICOM value as a bunch of bytes directly to the inner writer.

This method will perform the necessary padding (always with zeros) to ensure that the encoded value has an even number of bytes.

Source

pub fn bytes_written(&self) -> u64

Retrieve the number of bytes written so far by this printer.

Source

pub fn encode_offset_table(&mut self, table: &[u32]) -> Result<()>

Encode and write the values of a pixel data offset table.

Source

pub fn encode_primitive_element( &mut self, de: &DataElementHeader, value: &PrimitiveValue, ) -> Result<()>

Encode and write a data element with a primitive value.

This method will perform the necessary padding to ensure that the encoded value is an even number of bytes. Where applicable, this will use the inner text codec for textual values. The length property of the header is ignored, the true byte length of the value in its encoded form is used instead.

Trait Implementations§

Source§

impl<W: Debug, E: Debug, T: Debug> Debug for StatefulEncoder<W, E, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W, E, T> Freeze for StatefulEncoder<W, E, T>
where W: Freeze, E: Freeze, T: Freeze,

§

impl<W, E, T> RefUnwindSafe for StatefulEncoder<W, E, T>

§

impl<W, E, T> Send for StatefulEncoder<W, E, T>
where W: Send, E: Send, T: Send,

§

impl<W, E, T> Sync for StatefulEncoder<W, E, T>
where W: Sync, E: Sync, T: Sync,

§

impl<W, E, T> Unpin for StatefulEncoder<W, E, T>
where W: Unpin, E: Unpin, T: Unpin,

§

impl<W, E, T> UnwindSafe for StatefulEncoder<W, E, T>
where W: UnwindSafe, E: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more