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

Add attribute operations API #326

Merged
merged 16 commits into from
Apr 30, 2023
Merged

Add attribute operations API #326

merged 16 commits into from
Apr 30, 2023

Conversation

Enet4
Copy link
Owner

@Enet4 Enet4 commented Jan 28, 2023

This brings a new common API for applying specific changes to attributes in a DICOM object or object-like type. This has been implemented for all DICOM object types, namely InMemDicomObject, FileDicomObject and FileMetaTable.

Example of use:

use dicom_encoding::ops::{ApplyOp, AttributeAction, AttributeOp};

// given some DICOM object
let mut obj = open_file("I_00001.dcm")?;

// apply patient name change
obj.apply(AttributeOp {
  tag: tags::PATIENT_NAME,
  action: AttributeAction::ReplaceStr("Patient^Anonymous".into())
})?;
assert_eq!(
    obj.get(tags::PATIENT_NAME).unwrap().value().to_str().unwrap(),
    "Patient^Anonymous",
);

Summary

  • [core] Add DataElement::into_parts
  • [core] Add more PrimitiveValue::extend_* methods for other data types
  • [encoding] New attribute operations module ops, with AttributeOp, AttributeAction, and ApplyOp
  • [object] impl ApplyOp for current object types
  • [object] add infallible methods get and take for InMemDicomObject, return an option instead of a result.

@Enet4 Enet4 added enhancement A-lib Area: library C-object Crate: dicom-object C-core Crate: dicom-core labels Jan 28, 2023
@Enet4 Enet4 force-pushed the new/core/attribute-ops branch from 43abba0 to de7991f Compare February 4, 2023 13:41
@Enet4 Enet4 force-pushed the new/core/attribute-ops branch from de7991f to 8d7b565 Compare March 10, 2023 08:34
Enet4 added 15 commits March 15, 2023 18:27
- retrieve both parts of the data element,
  consuming it
- extend_i16
- extend_u16
- extend_f32
- extend_f64
- also update documentation of extend_*
  methods to emphasize the possible loss of precision
- `ops`, with `AttributeOpt` and `AttributeAction`
- add ops module for `ApplyError` and `ApplyError`
- impl ApplyOp for FileMetaTable
  -  currently only supports modifying known textual attributes
- impl ApplyOp for InMemDicomObject
- use if let instead of .map returning ()
- add ops module
- remove unnecessary links
- remove mention of nonexisting error module
@Enet4 Enet4 force-pushed the new/core/attribute-ops branch from 8d7b565 to 7d35344 Compare March 15, 2023 18:27
@Enet4 Enet4 merged commit 30e69bf into master Apr 30, 2023
@Enet4 Enet4 deleted the new/core/attribute-ops branch April 30, 2023 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lib Area: library C-core Crate: dicom-core C-object Crate: dicom-object enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant