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

Discussion: Investigate Into or TryInto impl to convert our Segments into the strong typed Segments in [hl7](https://docs.rs/hl7/0.0.2/hl7/) crate #29

Open
sempervictus opened this issue Aug 18, 2021 · 6 comments

Comments

@sempervictus
Copy link
Contributor

Querying into the MSH doesn't work well due to constraints around running iterators and ownership required to index into the fields - i tried a match pattern, its pretty gross.
What if we keep the MSH data structure as a GenericSegment but implement functional accessors to the well-known fields? Separators would move to the Message struct to be referenced or copied (its bytes) by its segments, and then every data element is consistent in both structure and impl. Thoughts?

@wokket
Copy link
Owner

wokket commented Aug 18, 2021

What if we removed all the MSH specific stuff from the main library, but added an example of how to 'wrap' the library to produce a strongly typed segment in a consuming app? MSH would be a good example (as everyone uses it) and also helps confirm the API is workable from the outside.

Thoughts?

@sempervictus
Copy link
Contributor Author

Thats kind of what i did in #31 - you can still call msg.msh().unwrap() to get a strongly-typed but non-iterable segment of fields over the original segment's string reference. I think this is the avenue toward "eating" the other library (presuming that author is ok with it) to have a bunch of strongly typed derivatives atop an efficient data/access layer with common iterator and search semantics over the generic sub-components.

@wokket
Copy link
Owner

wokket commented Aug 19, 2021

I have no desire to impinge on the other library, given it provides lovely rich fully typed segments etc and I'm not going there. If the two libraries end up working together well that's awesome, but not currently on my radar.

@sempervictus
Copy link
Contributor Author

Fair, though the idea in question isn't so much to impinge on theirs as to have an Into impl from the generic segments we have to their specific/typed segments or do it as we have msh() working in #34 (#31 really)

@wokket
Copy link
Owner

wokket commented Aug 19, 2021

Gotcha, Into impl for that library sounds cool. I'd want it behind a feature gate to reduce dependency size but would be worth investigation at some stage.

@wokket wokket changed the title Discussion: refactor segments to be generic with MSH-relevant accessors as Impl Discussion: Investigate Into or TryInto impl to convert our Segments into the strong typed Segments in [hl7](https://docs.rs/hl7/0.0.2/hl7/) crate Aug 19, 2021
@sempervictus
Copy link
Contributor Author

Agreed. The feature mechanisms is a very nice way to expose additional functionality while keeping the core lib clean and minimally opinionated.

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

No branches or pull requests

2 participants