Struct dicom_parser::stateful::decode::StatefulDecoder

source ·
pub struct StatefulDecoder<D, S, BD = BasicDecoder, TC = SpecificCharacterSet> { /* private fields */ }
Expand description

A stateful abstraction for the full DICOM content reading process. This type encapsulates the necessary codecs in order to be as autonomous as possible in the DICOM content reading process. S is the generic parameter type for the original source, D is the parameter type that the decoder interprets as, whereas DB is the parameter type for the basic decoder. TC defines the text codec used underneath.

Implementations§

source§

impl<S> StatefulDecoder<DynDecoder<S>, S>

source

pub fn new_with( from: S, ts: &TransferSyntax, charset: SpecificCharacterSet, position: u64 ) -> Result<Self>
where S: Read,

Create a new DICOM parser for the given transfer syntax, character set, and assumed position of the reader source.

source

pub fn new_with_ts(from: S, ts: &TransferSyntax, position: u64) -> Result<Self>
where S: Read,

Create a new DICOM parser for the given transfer syntax and assumed position of the reader source.

The default character set is assumed until a Specific Character Set attribute is found.

source§

impl<S> StatefulDecoder<ExplicitVRLittleEndianDecoder, S, LittleEndianBasicDecoder, DefaultCharacterSetCodec>
where S: Read,

source

pub fn file_header_parser(from: S) -> Self

Create a new DICOM stateful decoder for reading the file meta header, which is always in Explicit VR Little Endian.

source§

impl<D, S, BD, TC> StatefulDecoder<D, S, BD, TC>
where BD: BasicDecode, TC: TextCodec,

source

pub fn new( from: S, decoder: D, basic: BD, text: TC ) -> StatefulDecoder<D, S, BD, TC>

Create a new DICOM stateful decoder from its parts.

source

pub fn new_with_position( from: S, decoder: D, basic: BD, text: TC, position: u64 ) -> Self

Create a new DICOM stateful decoder from its parts, while assuming a base reading position.

position should be calculatd with care. Decoding or parsing errors may occur if this position does not match the real position of the reader.

source§

impl<D, S, BD, TC> StatefulDecoder<D, S, BD, TC>
where S: Seek, BD: BasicDecode, TC: TextCodec,

source

pub fn new_positioned( from: S, decoder: D, basic: BD, text: TC ) -> Result<Self, Error>

Create a new DICOM stateful decoder from its parts, while determining the data source’s current position via seek.

Trait Implementations§

source§

impl<D: Debug, S: Debug, BD: Debug, TC: Debug> Debug for StatefulDecoder<D, S, BD, TC>

source§

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

Formats the value using the given formatter. Read more
source§

impl<D, S, BD> StatefulDecode for StatefulDecoder<D, S, BD>
where D: DecodeFrom<S>, BD: BasicDecode, S: Read,

§

type Reader = S

source§

fn decode_header(&mut self) -> Result<DataElementHeader>

Same as Decode::decode_header over the bound source.
source§

fn decode_item_header(&mut self) -> Result<SequenceItemHeader>

Same as Decode::decode_item_header over the bound source.
source§

fn read_value(&mut self, header: &DataElementHeader) -> Result<PrimitiveValue>

Eagerly read the following data in the source as a primitive data value. When reading values in text form, a conversion to a more maleable type is attempted. Namely, numbers in text form (IS, DS) are converted to the corresponding binary number types, and date/time instances are decoded into binary date/time objects of types defined in the chrono crate. To avoid this conversion, see read_value_preserved. Read more
source§

fn read_value_preserved( &mut self, header: &DataElementHeader ) -> Result<PrimitiveValue>

Eagerly read the following data in the source as a primitive data value. Unlike read_value, this method will preserve the DICOM value’s original format: numbers saved as text, as well as dates and times, are read as strings. Read more
source§

fn read_value_bytes( &mut self, header: &DataElementHeader ) -> Result<PrimitiveValue>

Eagerly read the following data in the source as a primitive data value as bytes, regardless of its value representation. Read more
source§

fn position(&self) -> u64

Retrieve the known position of the inner reader source. If the stateful decoder was constructed at the beginning of the reader, this equals to the number of bytes read so far.
source§

fn read_to_vec(&mut self, length: u32, vec: &mut Vec<u8>) -> Result<()>

Read the following number of bytes into a vector.
source§

fn read_u32_to_vec(&mut self, length: u32, vec: &mut Vec<u32>) -> Result<()>

Read the following number of bytes as a sequence of unsigned 32 bit integers into a vector.
source§

fn read_to<W>(&mut self, length: u32, out: W) -> Result<()>
where Self: Sized, W: Write,

Read the following number of bytes into a generic writer.
source§

fn skip_bytes(&mut self, length: u32) -> Result<()>

Skip the following bytes into a vector, counting them as if they were read.
source§

fn seek(&mut self, position: u64) -> Result<()>
where Self::Reader: Seek,

Reposition the reader so that it starts reading at the reader’s given position. Read more

Auto Trait Implementations§

§

impl<D, S, BD, TC> Freeze for StatefulDecoder<D, S, BD, TC>
where S: Freeze, D: Freeze, BD: Freeze, TC: Freeze,

§

impl<D, S, BD, TC> RefUnwindSafe for StatefulDecoder<D, S, BD, TC>

§

impl<D, S, BD, TC> Send for StatefulDecoder<D, S, BD, TC>
where S: Send, D: Send, BD: Send, TC: Send,

§

impl<D, S, BD, TC> Sync for StatefulDecoder<D, S, BD, TC>
where S: Sync, D: Sync, BD: Sync, TC: Sync,

§

impl<D, S, BD, TC> Unpin for StatefulDecoder<D, S, BD, TC>
where S: Unpin, D: Unpin, BD: Unpin, TC: Unpin,

§

impl<D, S, BD, TC> UnwindSafe for StatefulDecoder<D, S, BD, TC>
where S: UnwindSafe, D: UnwindSafe, BD: UnwindSafe, TC: 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>,

§

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>,

§

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