Struct dicom_core::header::DataElement
source · [−]pub struct DataElement<I = EmptyObject, P = [u8; 0]> { /* private fields */ }
Expand description
A data type that represents and owns a DICOM data element.
This type is capable of representing any data element fully in memory,
whether it be a primitive value,
a nested data set (where each item contains an object of type I
),
or an encapsulated pixel data sequence (each item of type P
).
Implementations
sourceimpl<I, P> DataElement<I, P>
impl<I, P> DataElement<I, P>
sourcepub fn header(&self) -> &DataElementHeader
pub fn header(&self) -> &DataElementHeader
Retrieve the element header.
sourcepub fn vr(&self) -> VR
pub fn vr(&self) -> VR
Retrieve the value representation, which may be unknown or not applicable.
sourcepub fn into_value(self) -> Value<I, P>
pub fn into_value(self) -> Value<I, P>
Move the data value out of the element, discarding the rest. If the value is a sequence, its lifetime may still be bound to its original source.
sourceimpl<I, P> DataElement<I, P> where
I: HasLength,
impl<I, P> DataElement<I, P> where
I: HasLength,
sourcepub fn new<T>(tag: Tag, vr: VR, value: T) -> Self where
T: Into<Value<I, P>>,
pub fn new<T>(tag: Tag, vr: VR, value: T) -> Self where
T: Into<Value<I, P>>,
Create a primitive data element from the given parts, where the length is inferred from the value’s byte length.
If the value is textual,
the byte length of that value encoded in UTF-8 is assumed.
If you already have a length in this context,
prefer calling new_with_len
instead.
This method will not check whether the value representation is compatible with the given value.
sourcepub fn new_with_len<T>(tag: Tag, vr: VR, length: Length, value: T) -> Self where
T: Into<Value<I, P>>,
pub fn new_with_len<T>(tag: Tag, vr: VR, length: Length, value: T) -> Self where
T: Into<Value<I, P>>,
Create a primitive data element from the given parts.
This method will not check whether the length accurately represents the given value’s byte length, nor whether the value representation is compatible with the value.
sourcepub fn to_str(&self) -> Result<Cow<'_, str>, CastValueError>
pub fn to_str(&self) -> Result<Cow<'_, str>, CastValueError>
Retrieve the element’s value as a single clean string, with no trailing whitespace.
Returns an error if the value is not primitive.
sourcepub fn to_raw_str(&self) -> Result<Cow<'_, str>, CastValueError>
pub fn to_raw_str(&self) -> Result<Cow<'_, str>, CastValueError>
Retrieve the element’s value as a single raw string, with trailing whitespace kept.
Returns an error if the value is not primitive.
sourcepub fn to_clean_str(&self) -> Result<Cow<'_, str>, CastValueError>
👎 Deprecated: to_clean_str()
is now deprecated in favour of using to_str()
directly.
to_raw_str()
replaces the old functionality of to_str()
and maintains all trailing whitespace.
pub fn to_clean_str(&self) -> Result<Cow<'_, str>, CastValueError>
to_clean_str()
is now deprecated in favour of using to_str()
directly.
to_raw_str()
replaces the old functionality of to_str()
and maintains all trailing whitespace.
Retrieves the element’s value as a clean string
sourcepub fn to_bytes(&self) -> Result<Cow<'_, [u8]>, CastValueError>
pub fn to_bytes(&self) -> Result<Cow<'_, [u8]>, CastValueError>
Convert the full primitive value into raw bytes.
String values already encoded with the Str
and Strs
variants
are provided in UTF-8.
Returns an error if the value is not primitive.
sourcepub fn to_multi_str(&self) -> Result<Cow<'_, [String]>, CastValueError>
pub fn to_multi_str(&self) -> Result<Cow<'_, [String]>, CastValueError>
Convert the full value of the data element into a sequence of strings.
If the value is a primitive, it will be converted into
a vector of strings as described in PrimitiveValue::to_multi_str
.
Returns an error if the value is not primitive.
sourcepub fn to_int<T>(&self) -> Result<T, ConvertValueError> where
T: Clone,
T: NumCast,
T: FromStr<Err = ParseIntError>,
pub fn to_int<T>(&self) -> Result<T, ConvertValueError> where
T: Clone,
T: NumCast,
T: FromStr<Err = ParseIntError>,
Retrieve and convert the value of the data element into an integer.
If the value is a primitive,
it will be converted into an integer
as described in PrimitiveValue::to_int
.
Returns an error if the value is not primitive.
sourcepub fn to_multi_int<T>(&self) -> Result<Vec<T>, ConvertValueError> where
T: Clone,
T: NumCast,
T: FromStr<Err = ParseIntError>,
pub fn to_multi_int<T>(&self) -> Result<Vec<T>, ConvertValueError> where
T: Clone,
T: NumCast,
T: FromStr<Err = ParseIntError>,
Retrieve and convert the value of the data element into a sequence of integers.
If the value is a primitive, it will be converted into a vector of integers as described in PrimitiveValue::to_multi_int.
sourcepub fn to_float32(&self) -> Result<f32, ConvertValueError>
pub fn to_float32(&self) -> Result<f32, ConvertValueError>
Retrieve and convert the value of the data element into a single-precision floating point number.
If the value is a primitive, it will be converted into
a number as described in PrimitiveValue::to_float32
.
Returns an error if the value is not primitive.
sourcepub fn to_multi_float32(&self) -> Result<Vec<f32>, ConvertValueError>
pub fn to_multi_float32(&self) -> Result<Vec<f32>, ConvertValueError>
Retrieve and convert the value of the data element into a sequence of single-precision floating point numbers.
If the value is a primitive, it will be converted into
a vector of numbers as described in PrimitiveValue::to_multi_float32
.
Returns an error if the value is not primitive.
sourcepub fn to_float64(&self) -> Result<f64, ConvertValueError>
pub fn to_float64(&self) -> Result<f64, ConvertValueError>
Retrieve and convert the value of the data element into a double-precision floating point number.
If the value is a primitive, it will be converted into
a number as described in PrimitiveValue::to_float64
.
Returns an error if the value is not primitive.
sourcepub fn to_multi_float64(&self) -> Result<Vec<f64>, ConvertValueError>
pub fn to_multi_float64(&self) -> Result<Vec<f64>, ConvertValueError>
Retrieve and convert the value of the data element into a sequence of double-precision floating point numbers.
If the value is a primitive, it will be converted into
a vector of numbers as described in PrimitiveValue::to_multi_float64
.
Returns an error if the value is not primitive.
sourcepub fn to_date(&self) -> Result<DicomDate, ConvertValueError>
pub fn to_date(&self) -> Result<DicomDate, ConvertValueError>
Retrieve and convert the primitive value into a date.
If the value is a primitive, it will be converted into
a DicomDate
as described in PrimitiveValue::to_date
.
Returns an error if the value is not primitive.
sourcepub fn to_multi_date(&self) -> Result<Vec<DicomDate>, ConvertValueError>
pub fn to_multi_date(&self) -> Result<Vec<DicomDate>, ConvertValueError>
Retrieve and convert the primitive value into a sequence of dates.
If the value is a primitive, it will be converted into
a vector of DicomDate
as described in PrimitiveValue::to_multi_date
.
Returns an error if the value is not primitive.
sourcepub fn to_time(&self) -> Result<DicomTime, ConvertValueError>
pub fn to_time(&self) -> Result<DicomTime, ConvertValueError>
Retrieve and convert the primitive value into a time.
If the value is a primitive, it will be converted into
a DicomTime
as described in PrimitiveValue::to_time
.
Returns an error if the value is not primitive.
sourcepub fn to_multi_time(&self) -> Result<Vec<DicomTime>, ConvertValueError>
pub fn to_multi_time(&self) -> Result<Vec<DicomTime>, ConvertValueError>
Retrieve and convert the primitive value into a sequence of times.
If the value is a primitive, it will be converted into
a vector of DicomTime
as described in PrimitiveValue::to_multi_time
.
Returns an error if the value is not primitive.
sourcepub fn to_datetime(
&self,
default_offset: FixedOffset
) -> Result<DicomDateTime, ConvertValueError>
pub fn to_datetime(
&self,
default_offset: FixedOffset
) -> Result<DicomDateTime, ConvertValueError>
Retrieve and convert the primitive value into a date-time.
If the value is a primitive, it will be converted into
a DicomDateTime
as described in PrimitiveValue::to_datetime
.
Returns an error if the value is not primitive.
sourcepub fn to_multi_datetime(
&self,
default_offset: FixedOffset
) -> Result<Vec<DicomDateTime>, ConvertValueError>
pub fn to_multi_datetime(
&self,
default_offset: FixedOffset
) -> Result<Vec<DicomDateTime>, ConvertValueError>
Retrieve and convert the primitive value into a sequence of date-times.
If the value is a primitive, it will be converted into
a vector of DicomDateTime
as described in PrimitiveValue::to_multi_datetime
.
Returns an error if the value is not primitive.
sourceimpl<I, P> DataElement<I, P>
impl<I, P> DataElement<I, P>
sourcepub fn string(&self) -> Result<&str, CastValueError>
pub fn string(&self) -> Result<&str, CastValueError>
Get a single string value.
If it contains multiple strings, only the first one is returned.
An error is returned if the variant is not compatible.
To enable conversions of other variants to a textual representation,
see to_str()
instead.
sourcepub fn strings(&self) -> Result<&[String], CastValueError>
pub fn strings(&self) -> Result<&[String], CastValueError>
Get the inner sequence of string values
if the variant is either Str
or Strs
.
An error is returned if the variant is not compatible.
To enable conversions of other variants to a textual representation,
see to_str()
instead.
sourcepub fn date(&self) -> Result<DicomDate, CastValueError>
pub fn date(&self) -> Result<DicomDate, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn dates(&self) -> Result<&[DicomDate], CastValueError>
pub fn dates(&self) -> Result<&[DicomDate], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn time(&self) -> Result<DicomTime, CastValueError>
pub fn time(&self) -> Result<DicomTime, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn times(&self) -> Result<&[DicomTime], CastValueError>
pub fn times(&self) -> Result<&[DicomTime], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn datetime(&self) -> Result<DicomDateTime, CastValueError>
pub fn datetime(&self) -> Result<DicomDateTime, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn datetimes(&self) -> Result<&[DicomDateTime], CastValueError>
pub fn datetimes(&self) -> Result<&[DicomDateTime], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn uint8(&self) -> Result<u8, CastValueError>
pub fn uint8(&self) -> Result<u8, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn uint8_slice(&self) -> Result<&[u8], CastValueError>
pub fn uint8_slice(&self) -> Result<&[u8], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn uint16(&self) -> Result<u16, CastValueError>
pub fn uint16(&self) -> Result<u16, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn uint16_slice(&self) -> Result<&[u16], CastValueError>
pub fn uint16_slice(&self) -> Result<&[u16], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn int16(&self) -> Result<i16, CastValueError>
pub fn int16(&self) -> Result<i16, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn int16_slice(&self) -> Result<&[i16], CastValueError>
pub fn int16_slice(&self) -> Result<&[i16], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn uint32(&self) -> Result<u32, CastValueError>
pub fn uint32(&self) -> Result<u32, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn uint32_slice(&self) -> Result<&[u32], CastValueError>
pub fn uint32_slice(&self) -> Result<&[u32], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn int32(&self) -> Result<i32, CastValueError>
pub fn int32(&self) -> Result<i32, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn int32_slice(&self) -> Result<&[i32], CastValueError>
pub fn int32_slice(&self) -> Result<&[i32], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn int64(&self) -> Result<i64, CastValueError>
pub fn int64(&self) -> Result<i64, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn int64_slice(&self) -> Result<&[i64], CastValueError>
pub fn int64_slice(&self) -> Result<&[i64], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn uint64(&self) -> Result<u64, CastValueError>
pub fn uint64(&self) -> Result<u64, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn uint64_slice(&self) -> Result<&[u64], CastValueError>
pub fn uint64_slice(&self) -> Result<&[u64], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn float32(&self) -> Result<f32, CastValueError>
pub fn float32(&self) -> Result<f32, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn float32_slice(&self) -> Result<&[f32], CastValueError>
pub fn float32_slice(&self) -> Result<&[f32], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
sourcepub fn float64(&self) -> Result<f64, CastValueError>
pub fn float64(&self) -> Result<f64, CastValueError>
Get a single value of the requested type.
If it contains multiple values, only the first one is returned. An error is returned if the variant is not compatible.
sourcepub fn float64_slice(&self) -> Result<&[f64], CastValueError>
pub fn float64_slice(&self) -> Result<&[f64], CastValueError>
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
Trait Implementations
sourceimpl<I: Clone, P: Clone> Clone for DataElement<I, P>
impl<I: Clone, P: Clone> Clone for DataElement<I, P>
sourcefn clone(&self) -> DataElement<I, P>
fn clone(&self) -> DataElement<I, P>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<I: Debug, P: Debug> Debug for DataElement<I, P>
impl<I: Debug, P: Debug> Debug for DataElement<I, P>
sourceimpl<I, P> From<PrimitiveDataElement> for DataElement<I, P>
impl<I, P> From<PrimitiveDataElement> for DataElement<I, P>
sourcefn from(o: PrimitiveDataElement) -> Self
fn from(o: PrimitiveDataElement) -> Self
Converts to this type from the input type.
sourceimpl<I, P> HasLength for &DataElement<I, P>
impl<I, P> HasLength for &DataElement<I, P>
sourceimpl<I, P> HasLength for DataElement<I, P>
impl<I, P> HasLength for DataElement<I, P>
sourceimpl<'a, I, P> Header for &'a DataElement<I, P>
impl<'a, I, P> Header for &'a DataElement<I, P>
sourcefn is_item_delimiter(&self) -> bool
fn is_item_delimiter(&self) -> bool
Check whether this is the header of an item delimiter.
sourcefn is_sequence_delimiter(&self) -> bool
fn is_sequence_delimiter(&self) -> bool
Check whether this is the header of a sequence delimiter.
sourcefn is_encapsulated_pixeldata(&self) -> bool
fn is_encapsulated_pixeldata(&self) -> bool
Check whether this is the header of an encapsulated pixel data.
sourceimpl<I, P> Header for DataElement<I, P>
impl<I, P> Header for DataElement<I, P>
sourcefn is_item_delimiter(&self) -> bool
fn is_item_delimiter(&self) -> bool
Check whether this is the header of an item delimiter.
sourcefn is_sequence_delimiter(&self) -> bool
fn is_sequence_delimiter(&self) -> bool
Check whether this is the header of a sequence delimiter.
sourcefn is_encapsulated_pixeldata(&self) -> bool
fn is_encapsulated_pixeldata(&self) -> bool
Check whether this is the header of an encapsulated pixel data.
sourceimpl<I: PartialEq, P: PartialEq> PartialEq<DataElement<I, P>> for DataElement<I, P>
impl<I: PartialEq, P: PartialEq> PartialEq<DataElement<I, P>> for DataElement<I, P>
sourcefn eq(&self, other: &DataElement<I, P>) -> bool
fn eq(&self, other: &DataElement<I, P>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &DataElement<I, P>) -> bool
fn ne(&self, other: &DataElement<I, P>) -> bool
This method tests for !=
.
impl<I, P> StructuralPartialEq for DataElement<I, P>
Auto Trait Implementations
impl<I, P> RefUnwindSafe for DataElement<I, P> where
I: RefUnwindSafe,
P: RefUnwindSafe,
impl<I, P> Send for DataElement<I, P> where
I: Send,
P: Send,
impl<I, P> Sync for DataElement<I, P> where
I: Sync,
P: Sync,
impl<I, P> Unpin for DataElement<I, P> where
I: Unpin,
P: Unpin,
impl<I, P> UnwindSafe for DataElement<I, P> where
I: UnwindSafe + RefUnwindSafe,
P: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more