pub struct Field {
pub range: Range<usize>,
pub repeats: Vec<Repeat>,
}
Expand description
Represents an HL7v2 field
Fields§
§range: Range<usize>
The range (in char indices) in the original message where the field is located
repeats: Vec<Repeat>
The repeats found within the component. This will always be at least 1 element long, and the vast majority of the time will only be 1 element long. However, in the case of field repeats (“arrays”, really), all of the repeat data will be stored here
Implementations§
Source§impl Field
impl Field
Sourcepub fn repeat(&self, repeat: NonZeroUsize) -> Option<&Repeat>
pub fn repeat(&self, repeat: NonZeroUsize) -> Option<&Repeat>
Sourcepub fn repeat_mut(&mut self, repeat: NonZeroUsize) -> Option<&mut Repeat>
pub fn repeat_mut(&mut self, repeat: NonZeroUsize) -> Option<&mut Repeat>
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 field
§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");
let field = segment.field(NonZeroUsize::new(3).unwrap()).expect("can get field 3");
assert_eq!(field.source(message.source), "12345^^^MIE&1.2.840.114398.1.100&ISO^MR");
Sourcepub fn repeat_at_cursor(&self, cursor: usize) -> Option<(NonZeroUsize, &Repeat)>
pub fn repeat_at_cursor(&self, cursor: usize) -> Option<(NonZeroUsize, &Repeat)>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Field
impl<'de> Deserialize<'de> for Field
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 Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Freeze for Field
impl RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnwindSafe for Field
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.