Skip to main content

SystemRegistry

Struct SystemRegistry 

Source
pub struct SystemRegistry { /* private fields */ }
Expand description

An extensible set of SystemDefs. Seeded with the 17 built-in systems; register adds/refines more. Lookups are by id (and by human label, for importing label-keyed knowledge files). Cloneable and serialisable so an app can persist / ship an extended taxonomy.

Implementations§

Source§

impl SystemRegistry

Source

pub fn new_empty() -> Self

An empty registry (no systems). Use SystemRegistry::seed for the built-in 17.

Source

pub fn seed() -> Self

The built-in seed: the 17 systems from BODY_SYSTEMS, each enriched with its representation and overlay hosts (from super::model) and a default identity colour. Provenance = Seed.

Source

pub fn register(&mut self, def: SystemDef) -> &mut Self

Register (or refine) a system. If a system with the same id already exists it is replaced — a later, more-authoritative definition (e.g. an ontology pack) may correct a seed’s label/colour. Returns &mut Self for chaining.

Source

pub fn get(&self, id: &str) -> Option<&SystemDef>

Look up a system by id.

Source

pub fn contains(&self, id: &str) -> bool

Whether a system id is registered.

Source

pub fn get_by_label(&self, label: &str) -> Option<&SystemDef>

Look up a system by its human label (case-insensitive, trimmed) — for importing label-keyed knowledge files (e.g. condition-map.json keys systems by "Endocrine System").

Source

pub fn all(&self) -> &[SystemDef]

All registered systems, in registration order (the 17 seed order first).

Source

pub fn ids(&self) -> impl Iterator<Item = &str>

The registered ids, in order.

Source

pub fn len(&self) -> usize

Length.

Source

pub fn is_empty(&self) -> bool

when empty.

Source

pub fn label_for(&self, id: &str) -> String

The human label for a system id, or the id itself if unregistered (so nothing renders blank).

Source

pub fn plain_label_for(&self, id: &str) -> String

The plain-language label for a system id, or the id itself if unregistered.

Source

pub fn representation_of(&self, id: &str) -> SystemRepresentation

How a system is rendered — defaults to SystemRepresentation::DiscreteOrgans for an unregistered id (the safe default: try to paint an organ mesh if one turns up).

Source

pub fn overlay_hosts_of(&self, id: &str) -> &[String]

The overlay host system ids for a distributed system (empty for discrete or unregistered).

Source

pub fn color_of(&self, id: &str) -> [f32; 4]

The default identity colour for a system id, or NEUTRAL_SYSTEM_RGBA if unregistered.

Source

pub fn canonical_majors(&self) -> impl Iterator<Item = &SystemDef>

The canonical major organ systems (the classic 11 in the seed).

Source

pub fn sub_systems_of( &self, parent_id: &str, ) -> impl Iterator<Item = &SystemDef>

The direct sub-systems of parent_id (e.g. nervous → sensory / vestibular / ENS / glymphatic).

Source

pub fn relations_of(&self, id: &str) -> &[SystemRelation]

A system’s structural links to other systems (empty for unregistered or unlinked systems).

Trait Implementations§

Source§

impl Clone for SystemRegistry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SystemRegistry

Source§

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

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

impl Default for SystemRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SystemRegistry

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SystemRegistry

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

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

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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.