Skip to content

Commit 5833c8c

Browse files
authored
Return anyhow error instead of IO error (#905)
1 parent bf5df68 commit 5833c8c

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

crates/codegen/src/plugin.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
use anyhow::{anyhow, Result};
2-
use std::{
3-
borrow::Cow,
4-
fs,
5-
io::{self},
6-
path::Path,
7-
str,
8-
};
2+
use std::{borrow::Cow, fs, path::Path, str};
93

104
use super::bytecode;
115

@@ -60,7 +54,7 @@ impl Plugin {
6054
}
6155

6256
/// Constructs a new instance of Plugin from a given path.
63-
pub fn new_from_path<P: AsRef<Path>>(path: P) -> io::Result<Self> {
57+
pub fn new_from_path<P: AsRef<Path>>(path: P) -> Result<Self> {
6458
let bytes = fs::read(path)?;
6559
Ok(Self::new(bytes.into()))
6660
}
@@ -69,9 +63,7 @@ impl Plugin {
6963
pub fn as_bytes(&self) -> &[u8] {
7064
&self.bytes
7165
}
72-
}
7366

74-
impl Plugin {
7567
/// Generate valid QuickJS bytecode from Javascript using a Plugin.
7668
pub(crate) fn compile_source(&self, js_source_code: &[u8]) -> Result<Vec<u8>> {
7769
bytecode::compile_source(self.as_bytes(), js_source_code)

0 commit comments

Comments
 (0)