Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DICOM object writing #35

Merged
merged 18 commits into from
May 11, 2020
Merged

DICOM object writing #35

merged 18 commits into from
May 11, 2020

Conversation

Enet4
Copy link
Owner

@Enet4 Enet4 commented Apr 22, 2020

This is another bulky set of contributions that ultimately enable users of DICOM-rs to write objects to a file. Resolves #15 as the MVP to writing, future issues related with the writing process can be made into more specific issues.

This was accompanied by several major changes, but I will summarize them here:

  • substantially changed the parser and printer abstractions to be become stateful decoder and encoder abstractions, thus being easier to understand their purpose and behaviour: they are like plain encoders/decoders, but target a specific byte source/sink and are aware of changes to text encoding.
  • extended the dataset module with the IntoTokens trait and multiple useful implementations of it (including for the in-memory DICOM object type and for the file meta table).
  • new experimental dicom_value! macro for constructing primitive values of variable cardinality.
  • the method RootDicomObject.write_to_file(path) lets you write a complete DICOM object to disk.

Enet4 added 17 commits February 29, 2020 15:17
- rename parser to stateful decoder
- rename printer to stateful encoder
- reorganize modules accordingly
- change some value reading functions to use inner buffer
- [encoding] add generic lifetime to transfer_syntax encoder()
- already addressed in #22
- to `items` and `into_items`
- fix UI values being improperly separated by 00h
- fix character set changes not being triggered via read_value_preserved
- add a few tests to the stateful decoder
- fix `value_reader` to take without limit on unknown length
- add `HasLength` trait
-  rename `len` or `size` to `HasLength::length`
- relax constraints of `I` in `Value<I>`
- make a distinction between size and cardinality in DicomValueType
- add more impls to DataToken
- add IntoTokens and various implementations
- add `tokens` module, InMemObjectTokens turns objects into tokens
- rename `from_element_iter` and `from_iter_with_dict`
   - to `from_element_source` and `from_element_source_with_dict`
   - replace former names with non-fallible versions
Zero type enables representing DICOM values not containing objects
- do not impl EncodeTo for all Encode,
 - instead use wrapper type EncoderFor
- utility for creating primitive DICOM values of variable cardinality
- impl IntoTokens for &InMemDicomObject
- refactor current implementation
- make better FileMetaTableBuilder errors
- tweak FileMetaTableBuilder to automatically fill in meta group length
- add RootDicomObject::new_empty_with_meta
- add means to turn FileMetaTable into data elements (then into tokens)
- add RootDicomObject::write_to_file
write preamble and magic code via write_all instead of write
- make builder field setters generic
- apply padding to ensure even length
- file meta information group length is not included
- refactor object smoke_test to test writing and reading
- add builder test
@Enet4 Enet4 merged commit 7586321 into master May 11, 2020
@Enet4 Enet4 deleted the imp/stateful branch August 4, 2020 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Writing DICOM files?
1 participant