Struct hl7_parser::Repeat

source ·
pub struct Repeat {
    pub range: Range<usize>,
    pub components: Vec<Component>,
}
Expand description

Represents an HL7v2 repeat of a field

Fields§

§range: Range<usize>

The range (in char indices) in the original message where the repeat is located

§components: Vec<Component>

The components found within the component

Implementations§

source§

impl Repeat

source

pub fn component(&self, component: NonZeroUsize) -> Option<&Component>

Access a component via the 1-based HL7 component index

Returns

A reference to the component

source

pub fn component_mut( &mut self, component: NonZeroUsize ) -> Option<&mut Component>

Mutably access a component via the 1-based HL7 component index

Returns

A mutable reference to the component

source

pub fn source<'s>(&self, message_source: &'s str) -> &'s str

Given the source for the original message, extract the (raw) string for this repeat

Arguments
  • message_source - A string slice representing the original message source that was parsed
Examples
let message = include_str!("../test_assets/sample_adt_a04.hl7");
let message = ParsedMessage::parse(&message, true).expect("can parse message");

let segment = message.segment("AL1").expect("can get AL1 segment");
let field = segment.field(NonZeroUsize::new(5).unwrap()).expect("can get field 5");
let repeat = field.repeat(NonZeroUsize::new(2).unwrap()).expect("can get repeat 2");

assert_eq!(repeat.source(message.source), "RASH");
source

pub fn component_at_cursor( &self, cursor: usize ) -> Option<(NonZeroUsize, &Component)>

Locate a component at the cursor position

Arguments
  • cursor - The cursor location (0-based character index of the original message)
Returns

A tuple containing the HL7 component index (1-based) and a reference to the component. If the repeat doesn’t contain the cursor, returns None

Trait Implementations§

source§

impl Clone for Repeat

source§

fn clone(&self) -> Repeat

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Repeat

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Repeat

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<I: Into<usize>> Index<I> for &Repeat

§

type Output = Component

The returned type after indexing.
source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl PartialEq for Repeat

source§

fn eq(&self, other: &Repeat) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Repeat

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Repeat

source§

impl StructuralEq for Repeat

source§

impl StructuralPartialEq for Repeat

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,