pub struct ParseError {
pub kind: &'static str,
pub reason: &'static str,
pub input: String,
}Expand description
A lexical form did not match the grammar its type requires.
The input field carries at most ParseError::MAX_ECHO characters of the
offending text — enough to identify a malformed archetype id, not enough to
leak a clinical note that reached a parser by mistake.
Fields§
§kind: &'static strThe openEHR type that rejected the input, spelled as the specification
spells it: ARCHETYPE_ID, OBJECT_VERSION_ID, TERMINOLOGY_ID.
reason: &'static strWhy the grammar rejected it.
input: StringThe rejected text, truncated to ParseError::MAX_ECHO characters.
Implementations§
Source§impl ParseError
impl ParseError
Sourcepub const MAX_ECHO: usize = 96
pub const MAX_ECHO: usize = 96
The maximum number of characters of rejected input an error will repeat.
Sized to hold the longest identifier openEHR defines with room to spare
— a fully specialised ARCHETYPE_ID runs to roughly 80 characters — and
to be uselessly short for anything document-shaped.
Sourcepub fn new(kind: &'static str, reason: &'static str, input: &str) -> Self
pub fn new(kind: &'static str, reason: &'static str, input: &str) -> Self
Builds a parse error, truncating the echoed input on a character boundary.
use openehr::ParseError;
let e = ParseError::new("TERMINOLOGY_ID", "empty name", "");
assert_eq!(e.kind, "TERMINOLOGY_ID");Sourcepub fn invariant(class: &'static str, invariant: &'static str) -> Self
pub fn invariant(class: &'static str, invariant: &'static str) -> Self
Builds an error for a broken class invariant, echoing nothing.
Constructors use this rather than ParseError::new. The distinction
is not stylistic: a rejected identifier is design-time vocabulary and
safe to repeat, whereas the value that broke DV_TEXT’s invariant is
the clinical text itself. Same error type, two entry points, and the
one that could leak takes no value to leak.
use openehr::ParseError;
let e = ParseError::invariant("DV_QUANTITY", "Units_valid");
assert_eq!(e.input, "");Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseError
impl Debug for ParseError
Source§impl Display for ParseError
impl Display for ParseError
impl Eq for ParseError
Source§impl Error for ParseError
impl Error for ParseError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ParseError> for Error
impl From<ParseError> for Error
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Source§impl PartialEq for ParseError
impl PartialEq for ParseError
impl StructuralPartialEq for ParseError
Auto Trait Implementations§
impl Freeze for ParseError
impl RefUnwindSafe for ParseError
impl Send for ParseError
impl Sync for ParseError
impl Unpin for ParseError
impl UnsafeUnpin for ParseError
impl UnwindSafe for ParseError
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.