| 1 | use codewhale_config::{EntryRef, PluginAuthority}; |
| 2 | use codewhale_plugins::PluginRegistry; |
| 3 | use codewhale_plugins::composition_scope::SelectionRevision; |
| 4 | use codewhale_skills::{NativeSkillRef, NativeSkillRoots, SkillHostPort}; |
| 5 | |
| 6 | struct HostPort; |
| 7 | static PORT: HostPort = HostPort; |
| 8 | |
| 9 | pub(super) fn install() { |
| 10 | codewhale_skills::install_skill_host(&PORT); |
| 11 | } |
| 12 | |
| 13 | impl SkillHostPort for HostPort { |
| 14 | fn check_selection( |
| 15 | &self, |
| 16 | selection: Option<SelectionRevision>, |
| 17 | plugins: Option<&PluginRegistry>, |
| 18 | plugin_id: &str, |
| 19 | hash: &str, |
| 20 | scope: Option<&EntryRef>, |
| 21 | ) -> Result<(), String> { |
| 22 | super::manager() |
| 23 | .shared |
| 24 | .check_selection(selection, plugins, plugin_id, hash, scope) |
| 25 | } |
| 26 | |
| 27 | fn verify_native_skill( |
| 28 | &self, |
| 29 | authority: &PluginAuthority, |
| 30 | reference: &NativeSkillRef, |
| 31 | ) -> Result<(), String> { |
| 32 | super::skills::verify_native_skill(authority, reference) |
| 33 | } |
| 34 | |
| 35 | fn native_roots(&self, plugins: &PluginRegistry) -> NativeSkillRoots { |
| 36 | super::skills::roots_for_plugins(plugins) |
| 37 | .into_iter() |
| 38 | .map(|(root, authority, reference)| (root.snapshots, authority, reference)) |
| 39 | .collect() |
| 40 | } |
| 41 | } |
| 42 |