Struct LocationQuery

Source
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

Source

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 (space)
  • <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);
Source

pub fn new_segment<S: ToString>(segment: S) -> LocationQuery

Create a location query solely for a segment

Source

pub fn new_field<S, U, UErr>( segment: S, field: U, ) -> Result<LocationQuery, UErr>
where S: ToString, U: TryInto<NonZeroUsize, Error = UErr>,

Create a location query for a segment and a field

Source

pub fn new_field_repeat<S, U, UErr>( segment: S, field: U, repeat: U, ) -> Result<LocationQuery, UErr>
where S: ToString, U: TryInto<NonZeroUsize, Error = UErr>,

Create a location query for a segment, a field, and a repeat

Source

pub fn new_component<S, U, UErr>( segment: S, field: U, component: U, ) -> Result<LocationQuery, UErr>
where S: ToString, U: TryInto<NonZeroUsize, Error = UErr>,

Create a location query for a segment, a field, and a component

Source

pub fn new_repeat_component<S, U, UErr>( segment: S, field: U, repeat: U, component: U, ) -> Result<LocationQuery, UErr>
where S: ToString, U: TryInto<NonZeroUsize, Error = UErr>,

Create a location query for a segment, a field, a repeat, and a component

Source

pub fn new_sub_component<S, U, UErr>( segment: S, field: U, component: U, sub_component: U, ) -> Result<LocationQuery, UErr>
where S: ToString, U: TryInto<NonZeroUsize, Error = UErr>,

Create a location query for a segment, a field, a component, and a sub-component

Source

pub fn new_repeat_sub_component<S, U, UErr>( segment: S, field: U, repeat: U, component: U, sub_component: U, ) -> Result<LocationQuery, UErr>
where S: ToString, U: TryInto<NonZeroUsize, Error = UErr>,

Create a location query for a segment, a field, a component, and a sub-component

Trait Implementations§

Source§

impl Clone for LocationQuery

Source§

fn clone(&self) -> LocationQuery

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LocationQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LocationQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'l> From<&LocatedData<'l>> for LocationQuery

Source§

fn from(value: &LocatedData<'_>) -> Self

Converts to this type from the input type.
Source§

impl From<&LocationQuery> for LocationQuery

Source§

fn from(value: &LocationQuery) -> Self

Converts to this type from the input type.
Source§

impl<'l> From<LocatedData<'l>> for LocationQuery

Source§

fn from(value: LocatedData<'_>) -> Self

Converts to this type from the input type.
Source§

impl FromStr for LocationQuery

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for LocationQuery

Source§

fn eq(&self, other: &LocationQuery) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'s> TryFrom<&'s str> for LocationQuery

Source§

type Error = String

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'s str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<String> for LocationQuery

Source§

type Error = String

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for LocationQuery

Source§

impl StructuralPartialEq for LocationQuery

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.