Struct dicom_encoding::transfer_syntax::TransferSyntax

source ·
pub struct TransferSyntax<D = DynDataRWAdapter, R = DynPixelDataReader, W = DynPixelDataWriter> { /* private fields */ }
Expand description

A DICOM transfer syntax specifier.

Custom encoding and decoding capabilities are defined via the parameter types D and P, The type parameter D specifies an adapter for reading and writing data sets, whereas P specifies the encoder and decoder of encapsulated pixel data.

This type is usually consumed in its “type erased” form, with its default parameter types. On the other hand, implementers of TransferSyntax will typically specify concrete types for D and P, which are type-erased before registration. If the transfer syntax requires no data set codec, D can be assigned to the utility type NeverAdapter. If pixel data encoding/decoding is not needed or not supported, you can assign P to NeverPixelAdapter.

Implementations§

source§

impl<D, R, W> TransferSyntax<D, R, W>

source

pub const fn new( uid: &'static str, name: &'static str, byte_order: Endianness, explicit_vr: bool, codec: Codec<D, R, W> ) -> Self

Create a new transfer syntax descriptor.

Note that only transfer syntax implementers are expected to construct TS descriptors from scratch. For a practical usage of transfer syntaxes, one should look up an existing transfer syntax registry by UID.

§Example

To register a private transfer syntax in your program, use submit_transfer_syntax outside of a function body:

submit_transfer_syntax! {
    TransferSyntax::<NeverAdapter, NeverPixelAdapter, NeverPixelAdapter>::new(
        "1.3.46.670589.33.1.4.1",
        "CT-Private-ELE",
        Endianness::Little,
        true,
        Codec::EncapsulatedPixelData(None, None),
    )
}
source

pub const fn new_ele( uid: &'static str, name: &'static str, codec: Codec<D, R, W> ) -> Self

Create a new descriptor for a transfer syntax in explicit VR little endian.

Note that only transfer syntax implementers are expected to construct TS descriptors from scratch. For a practical usage of transfer syntaxes, one should look up an existing transfer syntax registry by UID.

§Example

To register a private transfer syntax in your program, use submit_transfer_syntax outside of a function body:

submit_transfer_syntax! {
    TransferSyntax::<NeverAdapter, NeverPixelAdapter, NeverPixelAdapter>::new_ele(
        "1.3.46.670589.33.1.4.1",
        "CT-Private-ELE",
        Codec::EncapsulatedPixelData(None, None),
    )
}

See submit_ele_transfer_syntax for an alternative.

source

pub const fn uid(&self) -> &'static str

Obtain this transfer syntax’ unique identifier.

source

pub const fn name(&self) -> &'static str

Obtain the name of this transfer syntax.

source

pub const fn endianness(&self) -> Endianness

Obtain this transfer syntax’ expected endianness.

source

pub fn codec(&self) -> &Codec<D, R, W>

Obtain this transfer syntax’ codec specification.

source

pub fn is_fully_supported(&self) -> bool

Check whether this transfer syntax specifier provides a complete implementation, meaning that it can both decode and encode in this transfer syntax.

source

pub fn is_codec_free(&self) -> bool

Check whether no codecs are required for this transfer syntax, meaning that a complete implementation is available and no pixel data conversion is required.

source

pub fn is_unsupported(&self) -> bool

Check whether neither reading nor writing of data sets is supported. If this is true, encoding and decoding will not be available.

source

pub fn is_unsupported_pixel_encapsulation(&self) -> bool

Check whether reading and writing the pixel data is unsupported. If this is true, encoding and decoding of the data set may still be possible, but the pixel data will only be available in its encapsulated form.

source

pub fn can_decode_all(&self) -> bool

Check whether this codec can fully decode both data sets and pixel data.

source

pub fn can_decode_dataset(&self) -> bool

Check whether this codec can decode the data set.

source

pub fn decoder<'s>(&self) -> Option<DynDecoder<dyn Read + 's>>

Retrieve the appropriate data element decoder for this transfer syntax. Can yield none if decoding is not supported.

The resulting decoder does not consider pixel data encapsulation or data set compression rules. This means that the consumer of this method needs to adapt the reader before using the decoder.

source

pub fn decoder_for<S>(&self) -> Option<DynDecoder<S>>
where Self: Sized, S: ?Sized + Read,

Retrieve the appropriate data element decoder for this transfer syntax and given reader type (this method is not object safe). Can yield none if decoding is not supported.

The resulting decoder does not consider pixel data encapsulation or data set compression rules. This means that the consumer of this method needs to adapt the reader before using the decoder.

source

pub fn encoder<'w>(&self) -> Option<DynEncoder<'w, dyn Write + 'w>>

Retrieve the appropriate data element encoder for this transfer syntax. Can yield none if encoding is not supported. The resulting encoder does not consider pixel data encapsulation or data set compression rules.

source

pub fn encoder_for<'w, T>(&self) -> Option<DynEncoder<'w, T>>
where Self: Sized, T: ?Sized + Write + 'w,

Retrieve the appropriate data element encoder for this transfer syntax and the given writer type (this method is not object safe). Can yield none if encoding is not supported. The resulting encoder does not consider pixel data encapsulation or data set compression rules.

source

pub fn basic_decoder(&self) -> BasicDecoder

Obtain a dynamic basic decoder, based on this transfer syntax’ expected endianness.

source

pub fn erased(self) -> TransferSyntax
where D: Send + Sync + 'static + DataRWAdapter<Box<dyn Read>, Box<dyn Write>, Reader = Box<dyn Read>, Writer = Box<dyn Write>>, R: Send + Sync + 'static + PixelDataReader, W: Send + Sync + 'static + PixelDataWriter,

Type-erase the pixel data or data set codec.

Trait Implementations§

source§

impl<D: Debug, R: Debug, W: Debug> Debug for TransferSyntax<D, R, W>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D, R, W> Freeze for TransferSyntax<D, R, W>
where R: Freeze, W: Freeze, D: Freeze,

§

impl<D, R, W> RefUnwindSafe for TransferSyntax<D, R, W>

§

impl<D, R, W> Send for TransferSyntax<D, R, W>
where R: Send, W: Send, D: Send,

§

impl<D, R, W> Sync for TransferSyntax<D, R, W>
where R: Sync, W: Sync, D: Sync,

§

impl<D, R, W> Unpin for TransferSyntax<D, R, W>
where R: Unpin, W: Unpin, D: Unpin,

§

impl<D, R, W> UnwindSafe for TransferSyntax<D, R, W>
where R: UnwindSafe, W: UnwindSafe, D: 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, 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.