pub struct Component {
pub range: Range<usize>,
pub sub_components: Vec<SubComponent>,
}
Expand description
Represents an HL7v2 sub-component
Fields§
§range: Range<usize>
The range (in char indices) in the original message where the component is located
sub_components: Vec<SubComponent>
The sub-components found within the component
Implementations§
Source§impl Component
impl Component
Sourcepub fn sub_component(
&self,
sub_component: NonZeroUsize,
) -> Option<&SubComponent>
pub fn sub_component( &self, sub_component: NonZeroUsize, ) -> Option<&SubComponent>
Access a sub-component via the 1-based HL7 sub-component index
§Returns
A reference to the sub-component
Sourcepub fn sub_component_mut(
&mut self,
sub_component: NonZeroUsize,
) -> Option<&mut SubComponent>
pub fn sub_component_mut( &mut self, sub_component: NonZeroUsize, ) -> Option<&mut SubComponent>
Mutably access a sub-component via the 1-based HL7 sub-component index
§Returns
A mutable reference to the sub-component
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 component
§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");
let repeat = field.repeat(NonZeroUsize::new(1).unwrap()).expect("can get repeat 1");
let component = repeat.component(NonZeroUsize::new(4).unwrap()).expect("can get component 4");
assert_eq!(component.source(message.source), "MIE&1.2.840.114398.1.100&ISO");
Sourcepub fn sub_component_at_cursor(
&self,
cursor: usize,
) -> Option<(NonZeroUsize, &SubComponent)>
pub fn sub_component_at_cursor( &self, cursor: usize, ) -> Option<(NonZeroUsize, &SubComponent)>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Component
impl<'de> Deserialize<'de> for Component
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 Component
impl StructuralPartialEq for Component
Auto Trait Implementations§
impl Freeze for Component
impl RefUnwindSafe for Component
impl Send for Component
impl Sync for Component
impl Unpin for Component
impl UnwindSafe for Component
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.