From 5d961b585003b886bf031bede9d2efbe23fec435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Istv=C3=A1n=20B=C3=ADr=C3=B3?= Date: Thu, 14 Nov 2024 17:05:28 +0100 Subject: [PATCH] fix compose wasm read --- wasm-rpc-stubgen/src/commands/composition.rs | 2 +- wasm-rpc-stubgen/src/fs.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wasm-rpc-stubgen/src/commands/composition.rs b/wasm-rpc-stubgen/src/commands/composition.rs index 256b4763..4746b64a 100644 --- a/wasm-rpc-stubgen/src/commands/composition.rs +++ b/wasm-rpc-stubgen/src/commands/composition.rs @@ -20,7 +20,7 @@ pub async fn compose( let mut graph = CompositionGraph::new(); - let socket = fs::read_to_string(source_wasm).context("Failed to read socket component")?; + let socket = fs::read(source_wasm).context("Failed to read socket component")?; let socket = Package::from_bytes("socket", None, socket, graph.types_mut())?; let socket = graph.register_package(socket)?; diff --git a/wasm-rpc-stubgen/src/fs.rs b/wasm-rpc-stubgen/src/fs.rs index 73b502f8..42048f4b 100644 --- a/wasm-rpc-stubgen/src/fs.rs +++ b/wasm-rpc-stubgen/src/fs.rs @@ -81,6 +81,11 @@ pub fn read_to_string>(path: P) -> anyhow::Result { .with_context(|| anyhow!("Failed to read to string, file: {}", path.display())) } +pub fn read>(path: P) -> anyhow::Result> { + let path = path.as_ref(); + std::fs::read(path).with_context(|| anyhow!("Failed to read file: {}", path.display())) +} + // Creates all missing parent directories if necessary and writes str to path. pub fn write_str, S: AsRef>(path: P, str: S) -> anyhow::Result<()> { let path = PathExtra(path);