pub struct Message { /* private fields */ }Expand description
A parsed HL7 v2 message.
The message owns a copy of the input text; all views borrow from it.
Implementations§
Source§impl Message
impl Message
Sourcepub fn parse(text: impl Into<String>) -> Result<Message, ParseError>
pub fn parse(text: impl Into<String>) -> Result<Message, ParseError>
Parse a message from text.
Sourcepub fn parse_bytes(bytes: &[u8]) -> Result<Message, ParseError>
pub fn parse_bytes(bytes: &[u8]) -> Result<Message, ParseError>
Parse a message from bytes that must be valid UTF-8.
Sourcepub fn parse_lossy(bytes: &[u8]) -> Result<Message, ParseError>
pub fn parse_lossy(bytes: &[u8]) -> Result<Message, ParseError>
Parse a message from bytes, replacing invalid UTF-8 sequences. Spans
refer to the converted text available through Message::raw, not to
the original bytes.
Sourcepub fn segment_count(&self) -> usize
pub fn segment_count(&self) -> usize
Number of segments.
Sourcepub fn segment_at(&self, index: usize) -> Option<Segment<'_>>
pub fn segment_at(&self, index: usize) -> Option<Segment<'_>>
The segment at position index (zero-based).
Sourcepub fn segment(&self, name: &str) -> Option<Segment<'_>>
pub fn segment(&self, name: &str) -> Option<Segment<'_>>
The first segment with the given name (case-insensitive).
Sourcepub fn segments_named(
&self,
name: &str,
) -> impl Iterator<Item = Segment<'_>> + '_
pub fn segments_named( &self, name: &str, ) -> impl Iterator<Item = Segment<'_>> + '_
All segments with the given name (case-insensitive).
Sourcepub fn get(&self, path: &str) -> Option<&str>
pub fn get(&self, path: &str) -> Option<&str>
Look up a value by path, e.g. PID-3.1. See Path for the syntax.
Returns None when the path does not parse or the addressed element is
absent. Use Path::parse first to distinguish the two.
Sourcepub fn get_decoded(&self, path: &str) -> Option<Cow<'_, str>>
pub fn get_decoded(&self, path: &str) -> Option<Cow<'_, str>>
Like Message::get but decodes escape sequences.
Sourcepub fn decode<'a>(&self, text: &'a str) -> Cow<'a, str>
pub fn decode<'a>(&self, text: &'a str) -> Cow<'a, str>
Decode escape sequences in text with this message’s encoding.
Sourcepub fn message_type(&self) -> Option<MessageType<'_>>
pub fn message_type(&self) -> Option<MessageType<'_>>
MSH-9, the message type.
Sourcepub fn control_id(&self) -> Option<&str>
pub fn control_id(&self) -> Option<&str>
MSH-10, the message control ID.