haste-pointer
Pointers into FHIR values, built on MetaValue from haste-reflect. A Path is a JSON Pointer style string such as /name/0/family/value: extend it with descend, split it with ascend into the parent path and the last Key, and resolve it against any &dyn MetaValue with get or get_typed::<T>. Field names containing / or ~ are escaped the JSON Pointer way (~1 and ~0). A TypedPointer<Root, T> pairs a shared root (Arc<Root>) with a position inside it: it knows its path and its current value, and descend::<Child>(&Key) only moves when the child really has that type.
haste-fhir-profiling reports validation failures at a Path, haste-testscript-runner walks fixtures with a TypedPointer, and the haste-access-control rule engine uses one to address the rules inside an AccessPolicyV2.
Install
Usage
use Arc;
use ;
use ;
let patient = new;
// Untyped: build a path and resolve it against any MetaValue.
let path = new.descend.descend.descend.descend;
assert_eq!;
assert_eq!;
// Typed: each step names the type it expects and answers None otherwise.
let family = new
.
.and_then
.and_then
.unwrap;
assert_eq!;
assert_eq!;
Key::parse reads a segment as Key::Index when it is a number and Key::Field otherwise, and TypedPointer::root() returns to the top of the resource.
Links
- API reference
- Source
- Rust SDK overview
- Related crates: haste-reflect, haste-fhir-model
- TypeScript equivalent: @haste-health/fhir-pointer
Part of Haste Health, licensed under Apache-2.0.