diff --git a/rust/pv_core/src/utils.rs b/rust/pv_core/src/utils.rs index 515f7270..27f7625f 100644 --- a/rust/pv_core/src/utils.rs +++ b/rust/pv_core/src/utils.rs @@ -1,17 +1,19 @@ // SPDX-License-Identifier: MIT // // Copyright IBM Corp. 2023 -use crate::{ - macros::{bail_spec, file_error}, - Error, FileAccessErrorType, FileIoErrorType, Result, -}; use std::{ fs::File, io::{Read, Write}, path::Path, }; + use zerocopy::{AsBytes, BigEndian, FromBytes, FromZeroes, U64}; +use crate::{ + macros::{bail_spec, file_error}, + Error, FileAccessErrorType, FileIoErrorType, Result, +}; + /// Trait that describes bitflags, represented by `T`. pub trait Flags: From + for<'a> From<&'a T> { /// Set the specified bit to one. @@ -184,6 +186,10 @@ pub fn try_parse_u64(hex_str: &str, ctx: &str) -> Result { /// Wraps [`File::open`] /// /// * `path` - Path to file +/// +/// # Errors +/// +/// This function will return errors according to [`File::open`]. pub fn open_file>(path: P) -> Result { File::open(&path).map_err(|e| Error::FileAccess { ty: FileAccessErrorType::Open, @@ -197,6 +203,10 @@ pub fn open_file>(path: P) -> Result { /// Wraps [`File::create`] /// /// * `path` - Path to file +/// +/// # Errors +/// +/// This function will return errors according to [`File::create`]. pub fn create_file>(path: P) -> Result { File::create(&path).map_err(|e| Error::FileAccess { ty: FileAccessErrorType::Create,