From cedd5503e666a16ff5a7e7248bc17d60df0735e2 Mon Sep 17 00:00:00 2001 From: mars Date: Tue, 15 Nov 2022 21:57:52 -0700 Subject: [PATCH] Use &str instead of String for protocol names --- src/backend/mod.rs | 2 +- src/backend/wasmtime.rs | 2 +- src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/mod.rs b/src/backend/mod.rs index b1a5859..b815501 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -48,7 +48,7 @@ pub trait Instance { /// userdata. Then, when the runtime calls back into the script, the /// userdata will be reinterpreted as a pointer and a method can be called /// on that object in memory. - fn bind_panel(&self, panel: PanelId, protocol: String, msg: Vec) -> u32; + fn bind_panel(&self, panel: PanelId, protocol: &str, msg: Vec) -> u32; fn update(&self, panel_ud: u32, dt: f32); diff --git a/src/backend/wasmtime.rs b/src/backend/wasmtime.rs index b6a82b9..1024aaa 100644 --- a/src/backend/wasmtime.rs +++ b/src/backend/wasmtime.rs @@ -189,7 +189,7 @@ impl WasmtimeInstance { } impl Instance for WasmtimeInstance { - fn bind_panel(&self, panel: PanelId, protocol: String, msg: Vec) -> u32 { + fn bind_panel(&self, panel: PanelId, protocol: &str, msg: Vec) -> u32 { let mut store = self.store.lock(); let protocol = store.data().message_new(protocol.as_bytes().to_vec()); let msg = store.data().message_new(msg); diff --git a/src/lib.rs b/src/lib.rs index cb9a03c..f356234 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,7 +45,7 @@ pub struct Script { } impl Script { - pub fn create_panel(&mut self, protocol: String, msg: Vec) -> anyhow::Result { + pub fn create_panel(&mut self, protocol: &str, msg: Vec) -> anyhow::Result { let id = PanelId(self.next_panel); self.next_panel += 1; let userdata = self.instance.bind_panel(id, protocol, msg);