Message

Struct Message 

Source
pub struct Message<'a> {
    pub source: &'a str,
    pub segments: Vec<Segment<'a>>,
    /* private fields */
}
Expand description

A Message is an entire HL7 message parsed into it’s constituent segments, fields, repeats and subcomponents, and it consists of (1 or more) Segments. Message parses the source string into &str slices (minimising copying)

Fields§

§source: &'a str§segments: Vec<Segment<'a>>

Implementations§

Source§

impl<'a> Message<'a>

Source

pub fn new(source: &'a str) -> Message<'a>

Source

pub fn segments_by_name( &self, name: &str, ) -> Result<Vec<&Segment<'a>>, Hl7ParseError>

Extracts generic elements for external use by matching first field to name

Source

pub fn segments_to_str_vecs( segments: Vec<&Segment<'a>>, ) -> Result<Vec<Vec<&'a str>>, Hl7ParseError>

Present input vectors of &generics to vectors of &str

Source

pub fn as_str(&self) -> &'a str

Returns the source string slice used to create this Message initially. This method does not allocate.

§Example:
let source = "MSH|^~\\&|GHH LAB|ELAB-3|GHH OE|BLDG4|200202150930||ORU^R01|CNTRL-3456|P|2.4";
let m = Message::try_from(source)?;
assert_eq!(source, m.as_str());
Source

pub fn get_separators(&self) -> Separators

Gets the delimiter information for this Message

Source

pub fn query<'b, S>(&self, idx: S) -> &'a str
where S: Into<&'b str>,

Access Segment, Field, or sub-field string references by string index

Source

pub fn parse_query_string(query: &str) -> Vec<&str>

Parse query/index string to fill-in missing values. Required when conumer requests “PID.F3.C1” to pass integers down to the usize indexers at the appropriate positions

Trait Implementations§

Source§

impl<'a> Clone for Message<'a>

Source§

fn clone(&self) -> Self

Creates a new cloned Message object referencing the same source slice as the original.

§Example:
let m = Message::try_from("MSH|^~\\&|GHH LAB|ELAB-3|GHH OE|BLDG4|200202150930||ORU^R01|CNTRL-3456|P|2.4")?;
let cloned = m.clone(); // this object is looking at the same string slice as m
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Message<'a>

Source§

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

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

impl<'a> Display for Message<'a>

Source§

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

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

impl<'a> Index<usize> for Message<'a>

Source§

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

Access Segment string reference by numeric index

Source§

type Output = &'a str

The returned type after indexing.
Source§

impl<'a> PartialEq for Message<'a>

Source§

fn eq(&self, other: &Message<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<&'a str> for Message<'a>

Source§

fn try_from(source: &'a str) -> Result<Self, Self::Error>

Takes the source HL7 string and parses it into this message. Segments and other data are slices (&str) into the source HL7

Source§

type Error = Hl7ParseError

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

impl<'a> StructuralPartialEq for Message<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Message<'a>

§

impl<'a> RefUnwindSafe for Message<'a>

§

impl<'a> Send for Message<'a>

§

impl<'a> Sync for Message<'a>

§

impl<'a> Unpin for Message<'a>

§

impl<'a> UnwindSafe for Message<'a>

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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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.