Skip to main content

choose_plugin_instance

Function choose_plugin_instance 

Source
pub fn choose_plugin_instance<'a, P>(
    vendor: &str,
    instances: impl IntoIterator<Item = (&'a str, &'a Value)>,
) -> Result<String, ChoosePluginError>
where P: for<'de> GtsDeserialize<'de> + GtsSchema,
Expand description

Selects the best plugin instance for the given vendor.

Accepts an iterator of (gts_id, content) pairs — typically produced from types_registry_sdk::GtsEntity:

choose_plugin_instance::<MyPluginSpecV1>(
    &self.vendor,
    instances.iter().map(|e| (e.gts_id.as_str(), &e.content)),
)

Deserializes each entry as BaseModkitPluginV1<P>, filters by vendor, and returns the gts_id of the instance with the lowest priority value.

§Type Parameters

  • P — The plugin-specific properties struct (e.g. AuthNResolverPluginSpecV1). Must be DeserializeOwned.

§Errors