pub trait DataDictionary {
type Entry: DataDictionaryEntry;
// Required methods
fn by_tag(&self, tag: Tag) -> Option<&Self::Entry>;
fn by_name(&self, name: &str) -> Option<&Self::Entry>;
// Provided methods
fn by_expr(&self, tag: &str) -> Option<&Self::Entry> { ... }
fn parse_tag(&self, tag: &str) -> Option<Tag> { ... }
fn parse_selector(
&self,
selector_text: &str,
) -> Result<AttributeSelector, ParseSelectorError> { ... }
}
Expand description
Type trait for a dictionary of DICOM attributes.
The main purpose of an attribute dictionary is to retrieve a record containing additional information about a data element, in one of the following ways:
- By DICOM tag, via
by_tag
; - By its keyword (also known as alias) via
by_name
; - By an expression which may either be a keyword
or a tag printed in one of its standard forms,
using
by_expr
.
These methods will return None
when the tag or name is not recognized by the dictionary.
In addition,
the data element dictionary provides
built-in DICOM tag and selector (path) parsers for convenience.
parse_tag
converts an arbitrary expression to a tag,
whereas parse_selector
produces an attribute selector.
Required Associated Types§
Sourcetype Entry: DataDictionaryEntry
type Entry: DataDictionaryEntry
The type of the dictionary entry.
Required Methods§
Sourcefn by_name(&self, name: &str) -> Option<&Self::Entry>
fn by_name(&self, name: &str) -> Option<&Self::Entry>
Fetch an entry by its usual alias (e.g. “PatientName” or “SOPInstanceUID”). Aliases (or keyword) are usually in UpperCamelCase, not separated by spaces, and are case sensitive.
Querying the dictionary by name is usually
slightly more expensive than by DICOM tag.
If the parameter provided is a string literal
(e.g. "StudyInstanceUID"
),
then it may be better to use by_tag
with a known tag constant
(such as tags::STUDY_INSTANCE_UID
from the dicom-dictionary-std
crate).
Provided Methods§
Sourcefn by_expr(&self, tag: &str) -> Option<&Self::Entry>
fn by_expr(&self, tag: &str) -> Option<&Self::Entry>
Fetch an entry by its alias or by DICOM tag expression.
This method accepts a tag descriptor in any of the following formats:
(gggg,eeee)
: a 4-digit hexadecimal group part and a 4-digit hexadecimal element part surrounded by parenthesesgggg,eeee
: a 4-digit hexadecimal group part and a 4-digit hexadecimal element part not surrounded by parenthesesKeywordName
: an exact match (case sensitive) by DICOM tag keyword
When failing to identify the intended syntax or the tag keyword,
None
is returned.
Sourcefn parse_tag(&self, tag: &str) -> Option<Tag>
fn parse_tag(&self, tag: &str) -> Option<Tag>
Use this data element dictionary to interpret a DICOM tag.
This method accepts a tag descriptor in any of the following formats:
(gggg,eeee)
: a 4-digit hexadecimal group part and a 4-digit hexadecimal element part surrounded by parenthesesgggg,eeee
: a 4-digit hexadecimal group part and a 4-digit hexadecimal element part not surrounded by parenthesesKeywordName
: an exact match (case sensitive) by DICOM tag keyword
When failing to identify the intended syntax or the tag keyword,
None
is returned.
Sourcefn parse_selector(
&self,
selector_text: &str,
) -> Result<AttributeSelector, ParseSelectorError>
fn parse_selector( &self, selector_text: &str, ) -> Result<AttributeSelector, ParseSelectorError>
Parse a string as an attribute selector.
Attribute selectors are defined by the syntax
( «key»([«item»])? . )* «key»
where_«key»
_ is either a DICOM tag or keyword
as accepted by this dictionary
when calling the method parse_tag
.
More details about the syntax can be found
in the documentation of AttributeSelector
.
Returns an error if the string does not follow the given syntax, or one of the key components could not be resolved.
§Examples of valid input:
(0002,00010)
: Transfer Syntax UID00101010
: Patient Age0040A168[0].CodeValue
: Code Value in first item of Concept Code SequenceSequenceOfUltrasoundRegions.RegionSpatialFormat
: Region Spatial Format in first item of Sequence of Ultrasound Regions