pub struct Pool {
pub skipped: Vec<(String, String)>,
pub missing: RefCell<BTreeSet<String>>,
pub borrowed: BTreeSet<String>,
/* private fields */
}Expand description
Every schema a package’s profiles may be based on: the package’s own, its dependencies’ and the core release’s.
Fields§
§skipped: Vec<(String, String)>Definitions that did not convert, with the reason.
missing: RefCell<BTreeSet<String>>Bases that were not found (compared over the core type instead).
borrowed: BTreeSet<String>Bases found only among the other package’s dependencies (see Pool::borrow_bases).
Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new(loaded: &Loaded) -> Self
pub fn new(loaded: &Loaded) -> Self
Examples found in repository?
21fn main() {
22 let args: Vec<String> = std::env::args().skip(1).collect();
23 let loaded = load(&args[0]).expect("load");
24 let pool = Pool::new(&loaded);
25 let profile = pool
26 .profiles()
27 .into_iter()
28 .find(|p| p.url == args[1] || p.name == args[1])
29 .expect("profile");
30 for path in &args[2..] {
31 let parts: Vec<&str> = path.split('.').collect();
32 match find(&profile.tree, &parts) {
33 Some(n) => println!(
34 "{path}: min={} max={:?} types={:?} ms={} slices={:?} children={:?}",
35 n.min,
36 n.max,
37 n.types,
38 n.must_support,
39 n.slices.keys().collect::<Vec<_>>(),
40 n.children.keys().collect::<Vec<_>>()
41 ),
42 None => println!("{path}: (absent)"),
43 }
44 }
45}More examples
21fn main() {
22 let spec = std::env::args().nth(1).expect("package");
23 let loaded = load(&spec).expect("load");
24 let pool = Pool::new(&loaded);
25 let (mut checked, mut differ) = (0, 0);
26 for profile in pool.profiles() {
27 let Some(definition) = loaded
28 .package
29 .definitions
30 .iter()
31 .find(|d| d.file == profile.file)
32 else {
33 continue;
34 };
35 for element in definition.json["snapshot"]["element"]
36 .as_array()
37 .into_iter()
38 .flatten()
39 {
40 let id = element["id"].as_str().unwrap_or_default();
41 let parts: Vec<&str> = id.split('.').skip(1).collect();
42 if parts.is_empty() || parts.iter().any(|p| p.contains("[x]:")) {
43 continue;
44 }
45 let Some(node) = find(&profile.tree, &parts) else {
46 continue;
47 };
48 checked += 1;
49 let min = element["min"].as_u64().unwrap_or(0) as u32;
50 let max = match element["max"].as_str() {
51 Some("*") => None,
52 Some(m) => m.parse().ok(),
53 None => None,
54 };
55 let ms = element["mustSupport"].as_bool().unwrap_or(false);
56 if node.min != min || node.max != max || node.must_support != ms {
57 differ += 1;
58 if differ <= 25 {
59 println!(
60 "{} {id}: tree {}..{:?} ms={} / snapshot {min}..{max:?} ms={ms}",
61 profile.name, node.min, node.max, node.must_support
62 );
63 }
64 }
65 }
66 }
67 println!("checked {checked} elements, {differ} differ");
68}Sourcepub fn pair(old: &Loaded, new: &Loaded) -> (Self, Self)
pub fn pair(old: &Loaded, new: &Loaded) -> (Self, Self)
The pools of two packages compared with each other, each lent the bases it lacks by the
other (Pool::borrow_bases).
Sourcepub fn borrow_bases(&mut self, other: &Pool)
pub fn borrow_bases(&mut self, other: &Pool)
Take the bases this package’s profiles need but its manifest does not provide from
other, the package compared with. US Core 6.1.0 bases a profile on SDC without listing
SDC; comparing that profile over the core type would report SDC’s own constraints as
changes. A base with the same canonical URL from the other side’s dependencies isolates
the package’s own changes.
Sourcepub fn profiles(&self) -> Vec<Profile>
pub fn profiles(&self) -> Vec<Profile>
The package’s profiles and extension definitions with their effective trees.
Examples found in repository?
21fn main() {
22 let args: Vec<String> = std::env::args().skip(1).collect();
23 let loaded = load(&args[0]).expect("load");
24 let pool = Pool::new(&loaded);
25 let profile = pool
26 .profiles()
27 .into_iter()
28 .find(|p| p.url == args[1] || p.name == args[1])
29 .expect("profile");
30 for path in &args[2..] {
31 let parts: Vec<&str> = path.split('.').collect();
32 match find(&profile.tree, &parts) {
33 Some(n) => println!(
34 "{path}: min={} max={:?} types={:?} ms={} slices={:?} children={:?}",
35 n.min,
36 n.max,
37 n.types,
38 n.must_support,
39 n.slices.keys().collect::<Vec<_>>(),
40 n.children.keys().collect::<Vec<_>>()
41 ),
42 None => println!("{path}: (absent)"),
43 }
44 }
45}More examples
21fn main() {
22 let spec = std::env::args().nth(1).expect("package");
23 let loaded = load(&spec).expect("load");
24 let pool = Pool::new(&loaded);
25 let (mut checked, mut differ) = (0, 0);
26 for profile in pool.profiles() {
27 let Some(definition) = loaded
28 .package
29 .definitions
30 .iter()
31 .find(|d| d.file == profile.file)
32 else {
33 continue;
34 };
35 for element in definition.json["snapshot"]["element"]
36 .as_array()
37 .into_iter()
38 .flatten()
39 {
40 let id = element["id"].as_str().unwrap_or_default();
41 let parts: Vec<&str> = id.split('.').skip(1).collect();
42 if parts.is_empty() || parts.iter().any(|p| p.contains("[x]:")) {
43 continue;
44 }
45 let Some(node) = find(&profile.tree, &parts) else {
46 continue;
47 };
48 checked += 1;
49 let min = element["min"].as_u64().unwrap_or(0) as u32;
50 let max = match element["max"].as_str() {
51 Some("*") => None,
52 Some(m) => m.parse().ok(),
53 None => None,
54 };
55 let ms = element["mustSupport"].as_bool().unwrap_or(false);
56 if node.min != min || node.max != max || node.must_support != ms {
57 differ += 1;
58 if differ <= 25 {
59 println!(
60 "{} {id}: tree {}..{:?} ms={} / snapshot {min}..{max:?} ms={ms}",
61 profile.name, node.min, node.max, node.must_support
62 );
63 }
64 }
65 }
66 }
67 println!("checked {checked} elements, {differ} differ");
68}Sourcepub fn type_of(&self, url: &str) -> Option<String>
pub fn type_of(&self, url: &str) -> Option<String>
The type a profile constrains (Patient for US Core Patient), or the type itself for a
core URL.
Sourcepub fn base_node(&self, type_name: &str, child: &str) -> Option<Node>
pub fn base_node(&self, type_name: &str, child: &str) -> Option<Node>
The core definition of element child of type type_name: what a child that only one
version constrains is compared with.
Sourcepub fn effective(&self, schema: &FhirSchema) -> Node
pub fn effective(&self, schema: &FhirSchema) -> Node
schema merged over its base chain, as one tree rooted at the constrained type.
Auto Trait Implementations§
impl !Freeze for Pool
impl !RefUnwindSafe for Pool
impl !Sync for Pool
impl Forget for Pool
impl Send for Pool
impl Unpin for Pool
impl UnsafeUnpin for Pool
impl UnwindSafe for Pool
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more