pub struct LocationQuery {
pub segment: String,
pub field: Option<NonZeroUsize>,
pub repeat: Option<NonZeroUsize>,
pub component: Option<NonZeroUsize>,
pub sub_component: Option<NonZeroUsize>,
}
Expand description
A query for a particular piece of a message, to be used in ParsedMessage::query (or ParsedMessageOwned::query)
Fields§
§segment: String
The segment identifier to query
field: Option<NonZeroUsize>
The 1-based field ID to optionally query
repeat: Option<NonZeroUsize>
The 1-based repeat ID to optionally query
component: Option<NonZeroUsize>
The 1-based component ID to optionally query
sub_component: Option<NonZeroUsize>
The 1-based sub-component ID to optionally query
Implementations§
Source§impl LocationQuery
impl LocationQuery
Sourcepub fn new<S: AsRef<str>>(source: S) -> Result<LocationQuery, String>
pub fn new<S: AsRef<str>>(source: S) -> Result<LocationQuery, String>
Create a new location query by attempting to parse a string query
Query is expected to be in the form of: <SEGMENT ID>[<SEP><FIELD>][\[<REPEAT>\]][<SEP><COMPONENT>][<SEP><SUB-COMPONENT>]
where:
<SEGMENT ID>
is 3 alpha-numeric characters which will be normalized to uppercase<SEP>
is one of.
,-
, or<FIELD>
is a non-zero integer specifying the field number<REPEAT>
is a non-zero integer specifying the repeat number<COMPONENT>
is a non-zero integer specifying the component number<SUB-COMPONENT>
is a non-zero integer specifying the sub-component number
§Examples
let query = LocationQuery::new("MSH.9").expect("can parse query");
assert_eq!(query.segment.as_str(), "MSH");
assert_eq!(query.field.unwrap().get(), 9);
assert!(query.component.is_none());
let query = LocationQuery::new("AL1.5[3]").expect("can parse query");
assert_eq!(query.segment.as_str(), "AL1");
assert_eq!(query.field.unwrap().get(), 5);
assert_eq!(query.repeat.unwrap().get(), 3);
assert!(query.component.is_none());
let query = LocationQuery::new("PID-3-4-2").expect("can parse query");
assert_eq!(query.segment.as_str(), "PID");
assert_eq!(query.field.unwrap().get(), 3);
assert_eq!(query.component.unwrap().get(), 4);
assert_eq!(query.sub_component.unwrap().get(), 2);
Sourcepub fn new_segment<S: ToString>(segment: S) -> LocationQuery
pub fn new_segment<S: ToString>(segment: S) -> LocationQuery
Create a location query solely for a segment
Sourcepub fn new_field<S, U, UErr>(
segment: S,
field: U,
) -> Result<LocationQuery, UErr>
pub fn new_field<S, U, UErr>( segment: S, field: U, ) -> Result<LocationQuery, UErr>
Create a location query for a segment and a field
Sourcepub fn new_field_repeat<S, U, UErr>(
segment: S,
field: U,
repeat: U,
) -> Result<LocationQuery, UErr>
pub fn new_field_repeat<S, U, UErr>( segment: S, field: U, repeat: U, ) -> Result<LocationQuery, UErr>
Create a location query for a segment, a field, and a repeat
Sourcepub fn new_component<S, U, UErr>(
segment: S,
field: U,
component: U,
) -> Result<LocationQuery, UErr>
pub fn new_component<S, U, UErr>( segment: S, field: U, component: U, ) -> Result<LocationQuery, UErr>
Create a location query for a segment, a field, and a component
Sourcepub fn new_repeat_component<S, U, UErr>(
segment: S,
field: U,
repeat: U,
component: U,
) -> Result<LocationQuery, UErr>
pub fn new_repeat_component<S, U, UErr>( segment: S, field: U, repeat: U, component: U, ) -> Result<LocationQuery, UErr>
Create a location query for a segment, a field, a repeat, and a component
Sourcepub fn new_sub_component<S, U, UErr>(
segment: S,
field: U,
component: U,
sub_component: U,
) -> Result<LocationQuery, UErr>
pub fn new_sub_component<S, U, UErr>( segment: S, field: U, component: U, sub_component: U, ) -> Result<LocationQuery, UErr>
Create a location query for a segment, a field, a component, and a sub-component
Sourcepub fn new_repeat_sub_component<S, U, UErr>(
segment: S,
field: U,
repeat: U,
component: U,
sub_component: U,
) -> Result<LocationQuery, UErr>
pub fn new_repeat_sub_component<S, U, UErr>( segment: S, field: U, repeat: U, component: U, sub_component: U, ) -> Result<LocationQuery, UErr>
Create a location query for a segment, a field, a component, and a sub-component
Trait Implementations§
Source§impl Clone for LocationQuery
impl Clone for LocationQuery
Source§fn clone(&self) -> LocationQuery
fn clone(&self) -> LocationQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LocationQuery
impl Debug for LocationQuery
Source§impl Display for LocationQuery
impl Display for LocationQuery
Source§impl<'l> From<&LocatedData<'l>> for LocationQuery
impl<'l> From<&LocatedData<'l>> for LocationQuery
Source§fn from(value: &LocatedData<'_>) -> Self
fn from(value: &LocatedData<'_>) -> Self
Source§impl From<&LocationQuery> for LocationQuery
impl From<&LocationQuery> for LocationQuery
Source§fn from(value: &LocationQuery) -> Self
fn from(value: &LocationQuery) -> Self
Source§impl<'l> From<LocatedData<'l>> for LocationQuery
impl<'l> From<LocatedData<'l>> for LocationQuery
Source§fn from(value: LocatedData<'_>) -> Self
fn from(value: LocatedData<'_>) -> Self
Source§impl FromStr for LocationQuery
impl FromStr for LocationQuery
Source§impl PartialEq for LocationQuery
impl PartialEq for LocationQuery
Source§impl<'s> TryFrom<&'s str> for LocationQuery
impl<'s> TryFrom<&'s str> for LocationQuery
Source§impl TryFrom<String> for LocationQuery
impl TryFrom<String> for LocationQuery
impl Eq for LocationQuery
impl StructuralPartialEq for LocationQuery
Auto Trait Implementations§
impl Freeze for LocationQuery
impl RefUnwindSafe for LocationQuery
impl Send for LocationQuery
impl Sync for LocationQuery
impl Unpin for LocationQuery
impl UnwindSafe for LocationQuery
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.