Skip to main content

Pool

Struct Pool 

Source
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

Source

pub fn new(loaded: &Loaded) -> Self

Examples found in repository?
examples/dump.rs (line 24)
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
Hide additional examples
examples/selfcheck.rs (line 24)
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}
Source

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).

Source

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.

Source

pub fn profiles(&self) -> Vec<Profile>

The package’s profiles and extension definitions with their effective trees.

Examples found in repository?
examples/dump.rs (line 26)
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
Hide additional examples
examples/selfcheck.rs (line 26)
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}
Source

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.

Source

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.

Source

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more