pub fn bytes_to_string(b: &[u8]) -> Result<String, KSMRError>Expand description
Converts a byte slice to a String using the specified encoding.
§Arguments
b- A byte slice (&[u8]) that needs to be converted to a String.
§Returns
A Result<String, std::str::Utf8Error> where:
Ok(String)contains the decoded string if successful.Err(std::str::Utf8Error)if the byte slice is not valid UTF-8.
§Examples
use keeper_secrets_manager_core::utils::bytes_to_string;
let bytes = b"Hello, world!";
let result = bytes_to_string(bytes);
assert_eq!(result.unwrap(), "Hello, world!");