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);