pub struct Segment {
pub name: String,
pub fields: Vec<Field>,
/* private fields */
}Expand description
An HL7 segment: a name (e.g. MSH, PID) followed by a list of Fields.
Fields§
§name: StringThe segment name (first three characters).
fields: Vec<Field>The fields of the segment. For MSH, index 0 is the field-delimiter field
and index 1 is the encoding-characters field.
Implementations§
Source§impl Segment
impl Segment
Sourcepub fn parse(raw: &str, enc: &HL7Encoding) -> Result<Self, Hl7Error>
pub fn parse(raw: &str, enc: &HL7Encoding) -> Result<Self, Hl7Error>
Parses a segment from a raw line, applying the MSH special-casing for the delimiter fields.
Sourcepub fn raw(&self, enc: &HL7Encoding) -> Option<&str>
pub fn raw(&self, enc: &HL7Encoding) -> Option<&str>
The raw value, or None when “present but null”.
Sourcepub fn value(&self, enc: &HL7Encoding) -> Option<String>
pub fn value(&self, enc: &HL7Encoding) -> Option<String>
The decoded value of the whole segment line.
Sourcepub fn sequence_no(&self) -> usize
pub fn sequence_no(&self) -> usize
The 0-based sequence number of the segment within its message.
Sourcepub fn add_empty_field(&mut self, enc: &HL7Encoding)
pub fn add_empty_field(&mut self, enc: &HL7Encoding)
Appends an empty field.
Sourcepub fn add_new_field_value(&mut self, content: &str, enc: &HL7Encoding)
pub fn add_new_field_value(&mut self, content: &str, enc: &HL7Encoding)
Appends a field parsed from content.
Sourcepub fn add_new_field(&mut self, field: Field)
pub fn add_new_field(&mut self, field: Field)
Appends a field.
Sourcepub fn add_new_field_at(
&mut self,
field: Field,
position: usize,
enc: &HL7Encoding,
)
pub fn add_new_field_at( &mut self, field: Field, position: usize, enc: &HL7Encoding, )
Inserts a field at a 1-based position, padding with blank fields when the position is beyond the current length.
Sourcepub fn field(&self, position: usize) -> Result<&Field, Hl7Error>
pub fn field(&self, position: usize) -> Result<&Field, Hl7Error>
Returns the field at the given 1-based position.
Sourcepub fn serialize(&self, out: &mut String, enc: &HL7Encoding)
pub fn serialize(&self, out: &mut String, enc: &HL7Encoding)
Serializes the segment into out.
Trait Implementations§
impl Eq for Segment
impl StructuralPartialEq for Segment
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnsafeUnpin for Segment
impl UnwindSafe for Segment
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