pub struct Separators {
pub field: char,
pub component: char,
pub subcomponent: char,
pub repetition: char,
pub escape: char,
pub lenient_newlines: bool,
}
Expand description
Separators used in HL7 messages
Fields§
§field: char
§component: char
§subcomponent: char
§repetition: char
§escape: char
§lenient_newlines: bool
Not a separator, but a flag to indicate that newlines should be leniently parsed
as part of the message. Enabling this flag will allow \n
and \r\n
to be treated
the same as \r
as the separator for segments.
Implementations§
Source§impl Separators
impl Separators
Sourcepub fn encode<'m>(&'m self, value: &'m str) -> EncodedSeparatorsDisplay<'m>
pub fn encode<'m>(&'m self, value: &'m str) -> EncodedSeparatorsDisplay<'m>
Encode a string that has separators into a string that escapes the separators with the escape characters
§Examples
use hl7_parser::message::Separators;
let separators = Separators::default();
let input = "foo|bar^baz&quux~quuz\\corge\rquack\nduck";
let expected = r"foo\F\bar\S\baz\T\quux\R\quuz\E\corge\X0D\quack\X0A\duck";
let actual = separators.encode(input).to_string();
assert_eq!(expected, actual);
Sourcepub fn decode<'m>(&'m self, value: &'m str) -> DecodedSeparatorsDisplay<'m>
pub fn decode<'m>(&'m self, value: &'m str) -> DecodedSeparatorsDisplay<'m>
Decode a string that has separators encoding values
§Examples
use hl7_parser::message::Separators;
let separators = Separators::default();
let input = r"foo\F\bar\S\baz\T\quux\R\quuz\E\corge\X0D\quack\X0A\duck\.br\";
let expected = "foo|bar^baz&quux~quuz\\corge\rquack\nduck\r";
let actual = separators.decode(input).to_string();
assert_eq!(expected, actual);
Sourcepub fn with_lenient_newlines(&mut self, lenient_newlines: bool) -> Self
pub fn with_lenient_newlines(&mut self, lenient_newlines: bool) -> Self
Allow lenient newlines in the message. This will allow \n
and \r\n
to be treated
the same as \r
as the separator for segments.
Trait Implementations§
Source§impl Clone for Separators
impl Clone for Separators
Source§fn clone(&self) -> Separators
fn clone(&self) -> Separators
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Separators
impl Debug for Separators
Source§impl Default for Separators
impl Default for Separators
Source§fn default() -> Self
fn default() -> Self
Default separators for HL7 messages
§Examples
use hl7_parser::message::Separators;
let separators = Separators::default();
assert_eq!(separators.field, '|');
assert_eq!(separators.component, '^');
assert_eq!(separators.subcomponent, '&');
assert_eq!(separators.repetition, '~');
assert_eq!(separators.escape, '\\');
Source§impl<'de> Deserialize<'de> for Separators
impl<'de> Deserialize<'de> for Separators
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
Source§impl Display for Separators
impl Display for Separators
Source§impl PartialEq for Separators
impl PartialEq for Separators
Source§impl Serialize for Separators
impl Serialize for Separators
impl Copy for Separators
impl Eq for Separators
impl StructuralPartialEq for Separators
Auto Trait Implementations§
impl Freeze for Separators
impl RefUnwindSafe for Separators
impl Send for Separators
impl Sync for Separators
impl Unpin for Separators
impl UnwindSafe for Separators
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