pub struct Segment {
pub range: Range<usize>,
pub fields: Vec<Field>,
}
Expand description
Represents an HL7v2 segment
Fields§
§range: Range<usize>
The range (in char indices) in the original message where the segment is located
fields: Vec<Field>
The fields found within the component
Implementations§
Source§impl Segment
impl Segment
Sourcepub fn field(&self, field: NonZeroUsize) -> Option<&Field>
pub fn field(&self, field: NonZeroUsize) -> Option<&Field>
Sourcepub fn field_mut(&mut self, field: NonZeroUsize) -> Option<&mut Field>
pub fn field_mut(&mut self, field: NonZeroUsize) -> Option<&mut Field>
Sourcepub fn source<'s>(&self, message_source: &'s str) -> &'s str
pub fn source<'s>(&self, message_source: &'s str) -> &'s str
Given the source for the original message, extract the (raw) string for this segment
§Arguments
message_source
- A string slice representing the original message source that was parsed
§Examples
let message = include_str!("../test_assets/sample_oru_r01_generic.hl7");
let message = ParsedMessage::parse(&message, true).expect("can parse message");
let segment = message.segment("PID").expect("can get PID segment");
assert_eq!(segment.source(message.source), "PID|1|12345|12345^^^MIE&1.2.840.114398.1.100&ISO^MR||MOUSE^MINNIE^S||19240101|F|||123 MOUSEHOLE LN^^FORT WAYNE^IN^46808|||||||||||||||||||");
Sourcepub fn field_at_cursor(&self, cursor: usize) -> Option<(NonZeroUsize, &Field)>
pub fn field_at_cursor(&self, cursor: usize) -> Option<(NonZeroUsize, &Field)>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Segment
impl<'de> Deserialize<'de> for Segment
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Segment
impl StructuralPartialEq for Segment
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnwindSafe for Segment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.