diff --git a/crates/primitives/src/fs.rs b/crates/primitives/src/fs.rs index 8e4e50acd6..60f46e4da2 100644 --- a/crates/primitives/src/fs.rs +++ b/crates/primitives/src/fs.rs @@ -108,6 +108,14 @@ pub fn read_to_string(path: impl AsRef) -> Result { fs::read_to_string(path).map_err(|err| FsPathError::read(err, path)) } +/// Read the entire contents of a file into a bytes vector. +/// +/// Wrapper for `std::fs::read` +pub fn read(path: impl AsRef) -> Result> { + let path = path.as_ref(); + fs::read(path).map_err(|err| FsPathError::read(err, path)) +} + /// Wrapper for `std::fs::write` pub fn write(path: impl AsRef, contents: impl AsRef<[u8]>) -> Result<()> { let path = path.as_ref();