DicomAttribute

Trait DicomAttribute 

Source
pub trait DicomAttribute: DicomValueType {
    type Item<'a>: HasLength
       where Self: 'a;
    type PixelData<'a>
       where Self: 'a;

    // Required methods
    fn to_primitive_value(&self) -> Result<PrimitiveValue, AttributeError>;
    fn item(&self, index: u32) -> Result<Self::Item<'_>, AttributeError>;
    fn num_items(&self) -> Option<u32>;
    fn fragment(
        &self,
        index: u32,
    ) -> Result<Self::PixelData<'_>, AttributeError>;

    // Provided methods
    fn num_fragments(&self) -> Option<u32> { ... }
    fn to_str(&self) -> Result<Cow<'_, str>, AttributeError> { ... }
    fn to_u16(&self) -> Result<u16, AttributeError> { ... }
    fn to_i32(&self) -> Result<i32, AttributeError> { ... }
    fn to_u32(&self) -> Result<u32, AttributeError> { ... }
    fn to_f32(&self) -> Result<f32, AttributeError> { ... }
    fn to_f64(&self) -> Result<f64, AttributeError> { ... }
    fn to_bytes(&self) -> Result<Cow<'_, [u8]>, AttributeError> { ... }
}
Expand description

Interface type for access to a DICOM object’ attribute in a DICOM object.

Accessing an attribute via the DicomObject trait will generally result in a value of this type, which can then be converted into a more usable form.

Both DicomValue and references to it implement this trait.

Required Associated Types§

Source

type Item<'a>: HasLength where Self: 'a

The data type of an item in a data set sequence

Source

type PixelData<'a> where Self: 'a

The data type of a single contiguous pixel data fragment

Required Methods§

Source

fn to_primitive_value(&self) -> Result<PrimitiveValue, AttributeError>

Obtain an in-memory representation of the primitive value, cloning the value if necessary.

An error is returned if the value is a data set sequence or an encapsulated pixel data fragment sequence.

Source

fn item(&self, index: u32) -> Result<Self::Item<'_>, AttributeError>

Obtain one of the items in the attribute, if the attribute value represents a data set sequence.

Returns an error if the attribute is not a sequence.

Source

fn num_items(&self) -> Option<u32>

Obtain the number of data set items or pixel data fragments, if the attribute value represents a data set sequence or pixel data. Returns None otherwise.

Source

fn fragment(&self, index: u32) -> Result<Self::PixelData<'_>, AttributeError>

Obtain one of the fragments in the attribute, if the attribute value represents a pixel data fragment sequence.

Returns an error if the attribute is not a pixel data sequence.

Provided Methods§

Source

fn num_fragments(&self) -> Option<u32>

Obtain the number of pixel data fragments, if the attribute value represents encapsulated pixel data.

It should equivalent to num_items, save for returning None if the attribute is a data set sequence.

Source

fn to_str(&self) -> Result<Cow<'_, str>, AttributeError>

Obtain the attribute’s value as a string, converting it if necessary.

Source

fn to_u16(&self) -> Result<u16, AttributeError>

Obtain the attribute’s value as a 16-bit unsigned integer, converting it if necessary.

Source

fn to_i32(&self) -> Result<i32, AttributeError>

Obtain the attribute’s value as a 32-bit signed integer, converting it if necessary.

Source

fn to_u32(&self) -> Result<u32, AttributeError>

Obtain the attribute’s value as a 32-bit unsigned integer, converting it if necessary.

Source

fn to_f32(&self) -> Result<f32, AttributeError>

Obtain the attribute’s value as a 32-bit floating-point number, converting it if necessary.

Source

fn to_f64(&self) -> Result<f64, AttributeError>

Obtain the attribute’s value as a 64-bit floating-point number, converting it if necessary.

Source

fn to_bytes(&self) -> Result<Cow<'_, [u8]>, AttributeError>

Obtain the attribute’s value as bytes, converting it if necessary.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'b, O, P> DicomAttribute for &'b DicomValue<O, P>
where O: HasLength + Clone, &'b O: HasLength, P: Clone,

Source§

type Item<'a> = &'b O where Self: 'a, O: 'a

Source§

type PixelData<'a> = &'b P where Self: 'a, P: 'a

Source§

fn to_primitive_value(&self) -> Result<PrimitiveValue, AttributeError>

Source§

fn item(&self, index: u32) -> Result<Self::Item<'_>, AttributeError>

Source§

fn num_items(&self) -> Option<u32>

Source§

fn fragment(&self, index: u32) -> Result<Self::PixelData<'_>, AttributeError>

Source§

fn num_fragments(&self) -> Option<u32>

Source§

fn to_str(&self) -> Result<Cow<'_, str>, AttributeError>

Source§

fn to_bytes(&self) -> Result<Cow<'_, [u8]>, AttributeError>

Source§

impl<L, R> DicomAttribute for Either<L, R>

Source§

type Item<'a> = Either<<L as DicomAttribute>::Item<'a>, <R as DicomAttribute>::Item<'a>> where Self: 'a

Source§

type PixelData<'a> = Either<<L as DicomAttribute>::PixelData<'a>, <R as DicomAttribute>::PixelData<'a>> where Self: 'a

Source§

fn to_primitive_value(&self) -> Result<PrimitiveValue, AttributeError>

Source§

fn item(&self, index: u32) -> Result<Self::Item<'_>, AttributeError>

Source§

fn num_items(&self) -> Option<u32>

Source§

fn fragment(&self, index: u32) -> Result<Self::PixelData<'_>, AttributeError>

Source§

impl<O, P> DicomAttribute for DicomValue<O, P>
where O: HasLength, for<'a> &'a O: HasLength,

Source§

type Item<'a> = &'a O where Self: 'a, O: 'a

Source§

type PixelData<'a> = &'a P where Self: 'a, P: 'a

Source§

fn to_primitive_value(&self) -> Result<PrimitiveValue, AttributeError>

Source§

fn item(&self, index: u32) -> Result<&O, AttributeError>

Source§

fn num_items(&self) -> Option<u32>

Source§

fn fragment(&self, index: u32) -> Result<Self::PixelData<'_>, AttributeError>

Source§

fn to_str(&self) -> Result<Cow<'_, str>, AttributeError>

Source§

fn to_bytes(&self) -> Result<Cow<'_, [u8]>, AttributeError>

Implementors§

Source§

impl DicomAttribute for FileMetaAttribute<'_>

Source§

type Item<'b> = EmptyObject where Self: 'b

Source§

type PixelData<'b> = Vec<u8> where Self: 'b