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

On-demand primitive value conversion and construction #56

Merged
merged 18 commits into from
Jul 5, 2020

Conversation

Enet4
Copy link
Owner

@Enet4 Enet4 commented Jul 1, 2020

This PR extends the available public API for PrimitiveValue in such a way that makes it more usable. This is deemed necessary before making string preservation the default behavior of the stateful decoder (see #9).

  • move value encoding and decoding code to the core crate:
    • encoding::decode::primitive_value becomes core::value:deserialize
    • encoding::encode::primitive_value becomes core::value:serialize
  • extend the functionality of the dicom_value! macro
  • provide more implementations of From
  • add method with default implementation HasLength::is_empty
  • add getters for zero-copy primitive value retrieval
  • add methods for retrieving values with possible conversions: to_str, to_bytes, to_int, to_multi_int, to_float32, to_multi_float32, to_float64, to_multi_float64, to_date, to_time, to_datetime.
  • implement Display for PrimitiveValue
  • re-export chrono crate in core

Enet4 added 17 commits June 21, 2020 16:53
- move value encoding/decoding logic to dicom-core
   - encoding::decode::primitive_value becomes core::value:deserialize
   - encoding::encode::primitive_value becomes core::value:serialize
- move trait method DicomValueType::is_empty to trait HashLength
-  improve documentation of DicomValueType::cardinality
- improve root-level documentation in core
- improved and extend to_str method to accommodate value type conversion
- new value::primitive module
- move dicom_value! macro to lib root
- new error type ConvertValueError
   - add variant to existing error types
- narrow errors of result types from value::deserialize
- improve documentation and behavior of dicom_value!
- improve documentation of PrimitiveValue
- impl From<Vec<u8>> for PrimitiveValue
- impl From<&[u8]> for PrimitiveValue
- impl Display for PrimitiveValue
- add PrimitiveValue::to_str
- add PrimitiveValue::to_bytes
   - required safe-transmute dependency for
   the binary slice to bytes conversion
- add PrimitiveValue::to_date
- Prefer standard From::from conversions here
- use macros to implement them en masse
- getters return Result<*, CastValueError> instead of Option<*>
- [parser] update use of getter in test
- generic method over the return type,
  which must be an integer and be convertible from string
- add InvalidValueReadError::NarrowConvert
- add num-traits as dependency to core
- apply change to more methods
- improve documentation
- to_multi_float32
- to_multi_float64
- add tests for to_multi_int and to_multi_float{32,64}
- on to_multi_*, return empty vector on Empty variant
@Enet4 Enet4 marked this pull request as ready for review July 2, 2020 23:06
@Enet4 Enet4 changed the title Deferred primitive value conversion On-demand primitive value conversion and construction Jul 4, 2020
@Enet4 Enet4 merged commit d85a363 into master Jul 5, 2020
@Enet4 Enet4 deleted the imp/deferred-value-conversion branch July 5, 2020 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant