Skip to main content

DescriptorProvider

Trait DescriptorProvider 

Source
pub trait DescriptorProvider {
    // Required methods
    fn models(&self) -> Vec<&'static ModelDescriptor>;
    fn enums(&self) -> Vec<&'static EnumDescriptor>;
    fn apps(&self) -> &'static [AppDescriptor];
    fn deferrability_specs(&self) -> Vec<&'static DeferrabilitySpec>;
}
Expand description

Source of the #[derive(Model)] descriptors a descriptor-dependent command operates on.

§What

Supplies the four descriptor streams the migration projection + docs renderer consume: models, enums, apps, and FK-deferrability sidecars.

§Why

Injecting this is what lets an adopter-linked djogi binary supply its own models in place of djogi-cli’s empty inventory (the standalone published binary links no model crates). It is the boundary between “djogi works in its own test suite” and “djogi works for someone who cargo add djogis it”.

§How

The only shipped implementation is InventoryDescriptorProvider, which reads the link-time inventory registry — exactly the descriptors compiled into the calling binary. Pass it to super::project_from_provider / super::generate_docs_with_provider.

§Where

djogi_cli::run_with_provider threads a &dyn DescriptorProvider to the per-command functions that need it. Adopters do not implement this trait — they link their model crates and the inventory provider sees them.

§Trust

This trait is intentionally open (not sealed) so tests and future providers (e.g. a fixture provider returning a fixed model set) may implement it. A custom provider is trusted, framework-shaped code, not an untrusted-input surface: it only supplies descriptors to the adopter’s own CLI invocation, where the adopter already controls the linked code. It cannot reach or corrupt any other process’s state.

§Boundary completeness

project_from_provider reads models/enums/apps/deferrability through this trait, so a non-inventory provider yields a complete projection. The relation-accessor collision gate (ReverseRelationMarker) is a link-time validation of the binary’s Rust accessors — not descriptor data — and stays an ambient pre-gate inside project_from_provider, documented as the one deliberate ambient read.

Required Methods§

Source

fn models(&self) -> Vec<&'static ModelDescriptor>

Model descriptors visible to this process.

Source

fn enums(&self) -> Vec<&'static EnumDescriptor>

Enum descriptors visible to this process.

Source

fn apps(&self) -> &'static [AppDescriptor]

App descriptors, INCLUDING the synthetic global bucket, sorted, with app-identity uniqueness validated — i.e. the same contract as AppRegistry::all, not a bare inventory::iter.

§Panics

The existing inventory implementation delegates to AppRegistry::all, which panics on first call if two app descriptors collide on label (the workspace-wide label-uniqueness invariant).

Source

fn deferrability_specs(&self) -> Vec<&'static DeferrabilitySpec>

FK-deferrability sidecars. The projection reads these to build the per-field (deferrable, initially_deferred) map; without it on the trait, a non-inventory provider’s projection would silently fall back to ambient globals and be incomplete.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§