2 unstable releases
Uses old Rust 2015
0.2.0 | Oct 31, 2018 |
---|---|
0.1.0 | Oct 24, 2018 |
#30 in #dicom
1MB
296 lines
dicom_dictionary_parser
A Rust library that allows to parse the various elements defined in DICOM standard part 6.
Full documentation can be found here.
Usage
Add this to your 'Cargo.toml':
[dependencies]
dicom_dictionary_parser = "0.1.0"
and this to your crate root:
extern crate dicom_dictionary_parser;
lib.rs
:
Library providing acess to the elements defined in the various tables of DICOM part 6. Currently, access to the following tables is provided:
- "Registry of DICOM Data Elements"
- "Registry of DICOM File Meta Elements"
- "Registry of DICOM Directory Structuring Elements"
- "Registry of DICOM Unique Identifiers (UIDs)"
Example - Writing data elements to file
extern crate dicom_dictionary_parser as dict_parser;
use std::fs::File;
use std::io::BufWriter;
use std::io::Write;
fn main() -> Result<(), Box<::std::error::Error>> {
let parser = dict_parser::Parser::new()?;
let data_elements = parser.parse_data_element_registry()?;
let file = File::create("dictionary.rs")?;
let mut buf_writer = BufWriter::new(file);
for data_element in data_elements {
let upper_case_keyword = data_element
.keyword
.replace("\u{200b}", "")
.replace("__", "_")
.to_uppercase();
buf_writer.write_all(
format!(
"const {}: Tag = Tag(0x{}, 0x{});\n",
upper_case_keyword,
&data_element.tag[1..5],
&data_element.tag[6..10])
.as_bytes())?;
}
Ok(())
}
Dependencies
~22MB
~460K SLoC