wokket / rust-hl7

Learning rust by playing with a HL7 parser. Use for real at your own risk!
19 stars 10 forks source link

Merge-squash rebase/flatten branch as GH went nuts #33

Closed sempervictus closed 3 years ago

sempervictus commented 3 years ago

GH seems to have gone nuts claming that the rebase/flatten branch somehow changes commits going back to before i even started work on this repo. So merge-squashing all the work into a single commit to avoid dealing with nonsense - if attribution of bugs down the line is an issue, feel free to blame me first and ask for a hand to resolve.

commit 44de81961ade4145ca5306d1c4b8dba4e0dc2fee (origin/refactor/flatten, refactor/flatten)
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Wed Aug 18 19:40:17 2021 -0400

CI: test/bench with features

commit bafe1ca912e21f8ac4d342d3a595feab3e04bb99
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Wed Aug 18 12:10:21 2021 -0400

Cleanup and test `Field::is_subdivided` method

commit b24570152e3be04f31249e27c519e41144bc23b6
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Wed Aug 18 11:22:48 2021 -0400

Field convenience method and housekeeping

commit fd0d43f5b8941b5e3c96cbb6d7dc4c5e8974e4c0
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Wed Aug 18 11:02:13 2021 -0400

Split field in repeat delim

Address #26 by updating `Field::parse()` to split on both the
component delimeter (as before) and the repeat delimeter to permit
component indexing/querying regardless of subdivision modality.

Testing:
  Add test per #26 to find R1 and R2 from `A~S`, passing with
--features string_index.

commit bb72ab58f12f6faa42c4ccd2511ff3561bd9909a
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Wed Aug 18 04:42:46 2021 -0400

Fix benchmark

commit f91cd5131ecc9eea0112bae3f286f9b8a0f642f1
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Wed Aug 18 04:17:17 2021 -0400

Implement `new(&str)` for Message

The removal of native implementation initializers for Message has
resulted in users having to `use std::convert::TryFrom` whenever
instantiating `Message` structs. Unlike the more common From trait,
this one is not always in-scope making users import it.

Add `Message::new(&str)` which synchronously returns a `Message`
directly without Result wrapping - intended for use when developers
are sure of what they're parsing and can afford to skip validation
and async dispatch.

Testing:
  Added test to compare the results of `new` and `from_str`
  All tests passing

commit 8931d7304012a32c4599122bd13730b526a1c97a
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Wed Aug 18 02:56:43 2021 -0400

Major refactor: flatten code and object structures

After converting Field from an enum to a Struct and implementing
various generic mechanisms for common functionality, we are seeing
legacy code and object structures cluttering and breaking efforts
respectively. The `MshSegment` does not behave like a generic one
in terms of structure or implementation, and being "in the line of
fire" whenever segments are used to be parsed out through a match
statement makes it very cumbersome, sometimes unworkable due to
borrow checks on the string references.

Remove the `Segment` enum and convert `GenericSegment` struct to be
the new `Segment` struct - possible because `Separators` live in
the `Message` structure permitting on-demand re-parse of a `Segment`
struct into any other named segment type such as `MshSegment`. This
is how the `msh()` implementation now works for `Message` - finding
the relevant `Segment` and returning a parsed `MshSegment` from it
and the `Message` `Separators` already stored.

This permits `query()` and `Index<&str>` mechanisms to search for
all types of segments and fields, using syntax a la `MSH.F3` for
which a test-case has been added to the feature-gated test.

Now that the object structures and interfaces are generic, simple,
and common - the code structure itself has been reorganized per #25
into a flat set of files within src/.

Testing:
  Updated test object derivations to remove destructuring of enums.
  Added check to string-index for MSH fields.
  All tests passing with `index_string` feature enabled and without

commit 6201ef6ec1fa1318e61ce4dd9967d85833e398e9
Author: RageLtMan <rageltman [at] sempervictus>
Date:   Wed Aug 18 00:48:04 2021 -0400

Move string indexing behind a feature flag

Instead of deprecating the `index(String)` and `index(&str)` calls
for `Message`, `GenericSegment`, and `Field`, move them behind a
feature flag for `string_index`.
The `query()` semantic has limits to how it handles called params
(attempts to convert the str idx calls to use `query()` reveal that
it converts an &str to str in the process), but the string indexing
approach isn't very Rusty in terms of idiomatic implementation
(despite bringing parity to libs in other languages). So instead of
throwing the baby out with the bath water, we can use feature flags
to allow users to choose how the library works for them.

Testing:
  Builds, passes tests, with the feature enabled and normally.
sempervictus commented 3 years ago

Supposedly fixed branch testing now, closing this giant merge thing