Skip to main content

PdpFactory

Trait PdpFactory 

Source
pub trait PdpFactory: Send + Sync {
    // Required methods
    fn kind(&self) -> &str;
    fn build(
        &self,
        config: &Value,
    ) -> Result<Arc<dyn PdpResolver>, Box<dyn Error + Send + Sync>>;
}
Expand description

Build a PdpResolver from a unified-config block. Implemented per PDP backend (cedar-direct, opa, …) and registered with the apl-cpex visitor so unified-config YAML can declare PDPs without the host pre-constructing them in code.

Hosts register a factory by handing it to apl-cpex’s AplOptions.pdp_factories. When the visitor walks the unified config and finds a global.apl.pdp[].kind matching the factory’s reported kind(), it calls build with the rest of that block.

The error type is Box<dyn Error + Send + Sync> to keep this trait in apl-core (which has no cpex deps). apl-cpex’s visitor wraps the boxed error into VisitorErrorPluginError::Config at the manager boundary.

Required Methods§

Source

fn kind(&self) -> &str

Identifies which kind: in a config block this factory handles. Convention: kebab-case matching the published PDP product name ("cedar-direct", "opa", …).

Source

fn build( &self, config: &Value, ) -> Result<Arc<dyn PdpResolver>, Box<dyn Error + Send + Sync>>

Build a resolver from the rest of the PDP config block (everything under the same map level as kind). Implementations parse their own config shape; missing or malformed fields surface here.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§