pub struct RelationRegistry { /* private fields */ }Expand description
Relation lookup tables for one snapshot of the schema.
Build once per schema reload and consume by &-reference from
every admin handler that needs it. Pure data — no interior
mutability, no cached queries, no hidden state.
belongs_to[("Appointment", "patient_id")] → ResolvedRelation {
target_model: "Patient",
target_table: "patients",
target_display_field: Some("full_name"),
…
}
has_many["Patient"] → [
InverseRelation { source_model: "Appointment", source_field: "patient_id", … },
InverseRelation { source_model: "Invoice", source_field: "patient_id", … },
]Implementations§
Source§impl RelationRegistry
impl RelationRegistry
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Empty registry. Every lookup returns None. Useful as a
safe default when the schema file is missing or fails to
parse — the admin falls back to raw-id rendering.
Sourcepub fn from_schema(schema: &Schema) -> Self
pub fn from_schema(schema: &Schema) -> Self
Sourcepub fn belongs_to(&self, model: &str, field: &str) -> Option<&ResolvedRelation>
pub fn belongs_to(&self, model: &str, field: &str) -> Option<&ResolvedRelation>
The ResolvedRelation for (model, field), if any.
Sourcepub fn belongs_to_of(&self, model: &str) -> &[ResolvedRelation]
pub fn belongs_to_of(&self, model: &str) -> &[ResolvedRelation]
Every forward relation owned by a source model. Used by the list handler to enumerate FK columns for prefetch + filters. Returns an empty slice when the model declares none.
Sourcepub fn has_many(&self, model: &str) -> &[InverseRelation]
pub fn has_many(&self, model: &str) -> &[InverseRelation]
Every incoming edge into model. Used by the inverse-panel
renderer and the delete guard.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true if the registry knows no relations at all. Cheap check
used by list / detail handlers to skip the prefetch machinery
entirely when the project has no annotations.
Sourcepub fn validate(&self, schema: &Schema) -> Vec<RegistryError>
pub fn validate(&self, schema: &Schema) -> Vec<RegistryError>
Walk every stored relation and report declarations that
reference models or columns not present in the schema. The
macro’s compile-time checks already catch these for declared
fields; this pass also covers hand-edited rustio.schema.json
files (the AI pipeline writes those).
Sourcepub fn iter_belongs_to(&self) -> impl Iterator<Item = &ResolvedRelation>
pub fn iter_belongs_to(&self) -> impl Iterator<Item = &ResolvedRelation>
A forward iterator over every ResolvedRelation in the registry, in deterministic order. Not called on hot paths; convenient for tests and CLI introspection commands.
Trait Implementations§
Source§impl Clone for RelationRegistry
impl Clone for RelationRegistry
Source§fn clone(&self) -> RelationRegistry
fn clone(&self) -> RelationRegistry
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 RelationRegistry
impl Debug for RelationRegistry
Source§impl Default for RelationRegistry
impl Default for RelationRegistry
Source§fn default() -> RelationRegistry
fn default() -> RelationRegistry
Auto Trait Implementations§
impl Freeze for RelationRegistry
impl RefUnwindSafe for RelationRegistry
impl Send for RelationRegistry
impl Sync for RelationRegistry
impl Unpin for RelationRegistry
impl UnsafeUnpin for RelationRegistry
impl UnwindSafe for RelationRegistry
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<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