Skip to content

Commit 80f8c5f

Browse files
committed
feat(wit)!: add plugin-api/host-state-plugin#get-repl-var so that plugin can access a variable if they know the name
BREAKING CHANGE: break plugin-api backwards compatibility by changing the wit contract
1 parent 053e812 commit 80f8c5f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

crates/pluginlab/src/store.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ impl crate::api::plugin_api::repl::api::http_client::Host for PluginHost {
8282
}
8383
}
8484

85+
///
86+
impl crate::api::plugin_api::repl::api::host_state_plugin::Host for PluginHost {
87+
async fn get_repl_var(&mut self, key: String) -> Option<String> {
88+
None
89+
// Can't do the following because `PluginHost` does not have access to repl_vars
90+
// we need to add a repl_vars field to PluginHost that points to the repl_vars field of WasiState
91+
// self.repl_vars.get(&key).cloned()
92+
}
93+
}
94+
8595
/// It is necessary to implement this trait on PluginHost because other parts rely on it.
8696
impl crate::api::plugin_api::repl::api::transport::Host for PluginHost {
8797
// This trait has no methods, so no implementation needed

crates/pluginlab/wit/plugin-api.wit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ interface http-client {
2323
get: func(url: string, headers: list<http-header>) -> result<http-response, string>;
2424
}
2525

26+
interface host-state-plugin {
27+
get-repl-var: func(key: string) -> option<string>;
28+
}
29+
2630
world plugin-api {
2731
import http-client;
32+
import host-state-plugin;
2833
export plugin;
2934
}

0 commit comments

Comments
 (0)