Enum dicom_core::value::Value
source · [−]pub enum Value<I = EmptyObject, P = [u8; 0]> {
Primitive(PrimitiveValue),
Sequence {
items: C<I>,
size: Length,
},
PixelSequence {
offset_table: C<u32>,
fragments: C<P>,
},
}
Expand description
Representation of a full DICOM value, which may be either primitive or another DICOM object.
I
is the complex type for nest data set items, which should usually
implement HasLength
.
P
is the encapsulated pixel data provider, which should usually
implement AsRef<[u8]>
.
Variants
Primitive(PrimitiveValue)
Primitive value.
Sequence
A complex sequence of items.
PixelSequence
Fields
fragments: C<P>
The sequence of compressed fragments.
An encapsulated pixel data sequence.
Implementations
sourceimpl<P> Value<EmptyObject, P>
impl<P> Value<EmptyObject, P>
sourceimpl<I> Value<I, [u8; 0]>
impl<I> Value<I, [u8; 0]>
sourcepub fn new_sequence<T>(items: T, length: Length) -> Self where
T: Into<C<I>>,
pub fn new_sequence<T>(items: T, length: Length) -> Self where
T: Into<C<I>>,
Construct a full DICOM data set sequence value from a list of items and length.
sourceimpl Value<EmptyObject, [u8; 0]>
impl Value<EmptyObject, [u8; 0]>
sourcepub fn new(value: PrimitiveValue) -> Self
pub fn new(value: PrimitiveValue) -> Self
Construct a DICOM value from a primitive value.
This is equivalent to Value::from
in behavior,
except that suitable type parameters are specified
instead of inferred.
sourceimpl<I, P> Value<I, P>
impl<I, P> Value<I, P>
sourcepub fn multiplicity(&self) -> u32
pub fn multiplicity(&self) -> u32
Obtain the number of individual values. In a primitive, this is the number of individual elements in the value. In a sequence item, this is the number of items. In a pixel sequence, this is currently set to 1 regardless of the number of compressed fragments or frames.
sourcepub fn primitive(&self) -> Option<&PrimitiveValue>
pub fn primitive(&self) -> Option<&PrimitiveValue>
Gets a reference to the primitive value.
sourcepub fn into_primitive(self) -> Option<PrimitiveValue>
pub fn into_primitive(self) -> Option<PrimitiveValue>
Retrieves the primitive value.
sourcepub fn into_items(self) -> Option<C<I>>
pub fn into_items(self) -> Option<C<I>>
Retrieves the items.
sourcepub fn offset_table(&self) -> Option<&[u32]>
pub fn offset_table(&self) -> Option<&[u32]>
Gets a reference to the encapsulated pixel data’s offset table.
sourceimpl<I, P> Value<I, P> where
I: HasLength,
impl<I, P> Value<I, P> where
I: HasLength,
sourcepub fn to_str(&self) -> Result<Cow<'_, str>, CastValueError>
pub fn to_str(&self) -> Result<Cow<'_, str>, CastValueError>
Convert the full primitive value into a clean string.
The value is converted into a strings
as described in PrimitiveValue::to_str
.
If the value contains multiple strings,
they are trimmed at the end and concatenated
(separated by the standard DICOM value delimiter '\\'
)
into an owned string.
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>
Convert the full primitive value into a single raw string, with trailing whitespace kept.
If the value contains multiple strings, they are concatenated
(separated by the standard DICOM value delimiter '\\'
)
into an owned string.
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.
Convert the full primitive value into a clean string.
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 primitive value 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_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_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 primitive value into an integer.
If the value is a primitive, it will be converted into
an integer as described in PrimitiveValue::to_int
.
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 primitive value 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 primitive value 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
.
sourcepub fn to_multi_float32(&self) -> Result<Vec<f32>, ConvertValueError>
pub fn to_multi_float32(&self) -> Result<Vec<f32>, ConvertValueError>
Retrieve and convert the primitive value 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
.
sourcepub fn to_float64(&self) -> Result<f64, ConvertValueError>
pub fn to_float64(&self) -> Result<f64, ConvertValueError>
Retrieve and convert the primitive value 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
.
sourcepub fn to_multi_float64(&self) -> Result<Vec<f64>, ConvertValueError>
pub fn to_multi_float64(&self) -> Result<Vec<f64>, ConvertValueError>
Retrieve and convert the primitive value 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
.
sourcepub fn to_date(&self) -> Result<DicomDate, ConvertValueError>
pub fn to_date(&self) -> Result<DicomDate, ConvertValueError>
Retrieve and convert the primitive value into a DicomDate
.
If the value is a primitive, it will be converted into
a DicomDate
as described in PrimitiveValue::to_date
.
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 DicomDate
s.
If the value is a primitive, it will be converted into
a vector of DicomDate
as described in PrimitiveValue::to_multi_date
.
sourcepub fn to_time(&self) -> Result<DicomTime, ConvertValueError>
pub fn to_time(&self) -> Result<DicomTime, ConvertValueError>
Retrieve and convert the primitive value into a DicomTime
.
If the value is a primitive, it will be converted into
a DicomTime
as described in PrimitiveValue::to_time
.
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 DicomTime
s.
If the value is a primitive, it will be converted into
a vector of DicomTime
as described in PrimitiveValue::to_multi_time
.
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 DicomDateTime
.
If the value is a primitive, it will be converted into
a DateTime
as described in PrimitiveValue::to_datetime
.
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 DicomDateTime
s.
If the value is a primitive, it will be converted into
a vector of DicomDateTime
as described in PrimitiveValue::to_multi_datetime
.
sourcepub fn to_date_range(&self) -> Result<DateRange, ConvertValueError>
pub fn to_date_range(&self) -> Result<DateRange, ConvertValueError>
Retrieve and convert the primitive value into a DateRange
.
If the value is a primitive, it will be converted into
a DateRange
as described in PrimitiveValue::to_date_range
.
sourcepub fn to_time_range(&self) -> Result<TimeRange, ConvertValueError>
pub fn to_time_range(&self) -> Result<TimeRange, ConvertValueError>
Retrieve and convert the primitive value into a TimeRange
.
If the value is a primitive, it will be converted into
a TimeRange
as described in PrimitiveValue::to_time_range
.
sourcepub fn to_datetime_range(
&self,
offset: FixedOffset
) -> Result<DateTimeRange, ConvertValueError>
pub fn to_datetime_range(
&self,
offset: FixedOffset
) -> Result<DateTimeRange, ConvertValueError>
Retrieve and convert the primitive value into a DateTimeRange
.
If the value is a primitive, it will be converted into
a DateTimeRange
as described in PrimitiveValue::to_datetime_range
.
sourcepub fn to_tag(&self) -> Result<Tag, CastValueError>
pub fn to_tag(&self) -> Result<Tag, CastValueError>
Retrieves the primitive value as a DICOM tag.
sourcepub fn to_person_name(&self) -> Result<PersonName<'_>, ConvertValueError>
pub fn to_person_name(&self) -> Result<PersonName<'_>, ConvertValueError>
Retrieves the primitive value as a PersonName
.
sourceimpl<I, P> Value<I, P>
impl<I, P> Value<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 tag(&self) -> Result<Tag, CastValueError>
pub fn tag(&self) -> Result<Tag, 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.
Get a sequence of values of the requested type without copying.
An error is returned if the variant is not compatible.
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, P> DicomValueType for Value<I, P>
impl<I, P> DicomValueType for Value<I, P>
sourcefn value_type(&self) -> ValueType
fn value_type(&self) -> ValueType
Retrieve the specific type of this value.
sourcefn cardinality(&self) -> usize
fn cardinality(&self) -> usize
Retrieve the number of elements contained in the DICOM value. Read more
sourceimpl<I, P> From<PrimitiveValue> for Value<I, P>
impl<I, P> From<PrimitiveValue> for Value<I, P>
sourcefn from(v: PrimitiveValue) -> Self
fn from(v: PrimitiveValue) -> Self
Converts to this type from the input type.
impl<I, P> StructuralPartialEq for Value<I, P>
Auto Trait Implementations
impl<I, P> RefUnwindSafe for Value<I, P> where
I: RefUnwindSafe,
P: RefUnwindSafe,
impl<I, P> Send for Value<I, P> where
I: Send,
P: Send,
impl<I, P> Sync for Value<I, P> where
I: Sync,
P: Sync,
impl<I, P> Unpin for Value<I, P> where
I: Unpin,
P: Unpin,
impl<I, P> UnwindSafe for Value<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