dicom_parser::stateful::decode

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

Source§

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

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