pub struct SegmentBuilder {
pub name: String,
pub fields: HashMap<usize, FieldBuilder>,
}
Expand description
A builder for constructing HL7 segments.
Fields§
§name: String
§fields: HashMap<usize, FieldBuilder>
Implementations§
Source§impl SegmentBuilder
impl SegmentBuilder
Sourcepub fn new<S: ToString>(name: S) -> Self
pub fn new<S: ToString>(name: S) -> Self
Create a new segment builder with the given name. No fields are added.
Sourcepub fn push_field(&mut self, field: FieldBuilder)
pub fn push_field(&mut self, field: FieldBuilder)
Append a field to the segment. Fields will be output in the order they are added.
Sourcepub fn fields(&self) -> &HashMap<usize, FieldBuilder>
pub fn fields(&self) -> &HashMap<usize, FieldBuilder>
Get the fields in the segment.
Sourcepub fn fields_mut(&mut self) -> &mut HashMap<usize, FieldBuilder>
pub fn fields_mut(&mut self) -> &mut HashMap<usize, FieldBuilder>
Get a mutable reference to the fields in the segment.
Sourcepub fn field(&self, index: usize) -> Option<&FieldBuilder>
pub fn field(&self, index: usize) -> Option<&FieldBuilder>
Get a field by index (1-based).
Sourcepub fn field_mut(&mut self, index: usize) -> Option<&mut FieldBuilder>
pub fn field_mut(&mut self, index: usize) -> Option<&mut FieldBuilder>
Get a mutable reference to a field by index (1-based).
Sourcepub fn remove_field(&mut self, index: usize) -> Option<FieldBuilder>
pub fn remove_field(&mut self, index: usize) -> Option<FieldBuilder>
Remove a field by index (1-based).
Sourcepub fn set_field(&mut self, index: usize, field: FieldBuilder)
pub fn set_field(&mut self, index: usize, field: FieldBuilder)
Set a field in the segment. (1-based)
Sourcepub fn set_field_value<S: ToString>(&mut self, index: usize, value: S)
pub fn set_field_value<S: ToString>(&mut self, index: usize, value: S)
Set the value of a field in the segment. (1-based)
Sourcepub fn with_field<F: Into<FieldBuilder>>(self, index: usize, field: F) -> Self
pub fn with_field<F: Into<FieldBuilder>>(self, index: usize, field: F) -> Self
Add a field to the segment. (1-based)
Sourcepub fn with_field_value<S: ToString>(self, index: usize, value: S) -> Self
pub fn with_field_value<S: ToString>(self, index: usize, value: S) -> Self
Add a field with a value to the segment. (1-based)
Sourcepub fn display<'a>(
&'a self,
separators: &'a Separators,
) -> SegmentBuilderDisplay<'a>
pub fn display<'a>( &'a self, separators: &'a Separators, ) -> SegmentBuilderDisplay<'a>
Display the segment using the given separators.
Trait Implementations§
Source§impl Clone for SegmentBuilder
impl Clone for SegmentBuilder
Source§fn clone(&self) -> SegmentBuilder
fn clone(&self) -> SegmentBuilder
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 SegmentBuilder
impl Debug for SegmentBuilder
Source§impl Default for SegmentBuilder
impl Default for SegmentBuilder
Source§fn default() -> SegmentBuilder
fn default() -> SegmentBuilder
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SegmentBuilder
impl<'de> Deserialize<'de> for SegmentBuilder
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<'m> From<&'m Segment<'m>> for SegmentBuilder
impl<'m> From<&'m Segment<'m>> for SegmentBuilder
Source§impl PartialEq for SegmentBuilder
impl PartialEq for SegmentBuilder
Source§impl Serialize for SegmentBuilder
impl Serialize for SegmentBuilder
impl Eq for SegmentBuilder
impl StructuralPartialEq for SegmentBuilder
Auto Trait Implementations§
impl Freeze for SegmentBuilder
impl RefUnwindSafe for SegmentBuilder
impl Send for SegmentBuilder
impl Sync for SegmentBuilder
impl Unpin for SegmentBuilder
impl UnwindSafe for SegmentBuilder
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