pub struct Subcomponent<'m> {
pub value: &'m str,
pub range: Range<usize>,
}
Expand description
A subcomponent is the smallest unit of data in an HL7 message. It is a string that may contain escape sequences to encode the separators. It is the only type that does not have a separator character. It is always contained within a component.
For parsing performance reasons, the subcomponent does not decode the escape sequences when it is parsed. Instead, the escape sequences are decoded when the subcomponent is displayed. This allows the subcomponent to be parsed without allocating a new string for the decoded value.
Fields§
§value: &'m str
The raw value of the subcomponent, including escape sequences
range: Range<usize>
The range of the subcomponent in the original message
Implementations§
Source§impl<'m> Subcomponent<'m>
impl<'m> Subcomponent<'m>
Sourcepub fn display(&'m self, separators: &'m Separators) -> SubcomponentDisplay<'m>
pub fn display(&'m self, separators: &'m Separators) -> SubcomponentDisplay<'m>
Display the subcomponent value, using the separators to decode escape sequences
by default. Note: if you want to display the raw value without decoding escape
sequences, use the #
flag, e.g. format!("{:#}", subcomponent.display(separators))
§Examples
use hl7_parser::message::{Separators, Subcomponent};
let separators = Separators::default();
let subcomponent = Subcomponent {
value: r"foo\F\bar",
range: 0..1, // ignore
};
assert_eq!(format!("{}", subcomponent.display(&separators)), "foo|bar");
assert_eq!(format!("{:#}", subcomponent.display(&separators)), r"foo\F\bar");
Trait Implementations§
Source§impl<'m> Clone for Subcomponent<'m>
impl<'m> Clone for Subcomponent<'m>
Source§fn clone(&self) -> Subcomponent<'m>
fn clone(&self) -> Subcomponent<'m>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more