Replace .unwrap() with ? operator

This commit is contained in:
Brandon Vandegrift
2023-09-12 08:06:49 -04:00
parent c2c607efac
commit ac8bbe9a83
4 changed files with 88 additions and 96 deletions

View File

@@ -66,10 +66,15 @@ fn take_veilid_api() -> Result<veilid_core::VeilidAPI, veilid_core::VeilidAPIErr
}
// Marshalling helpers
pub fn unmarshall(b64: String) -> Vec<u8> {
pub fn unmarshall(b64: String) -> APIResult<Vec<u8>> {
data_encoding::BASE64URL_NOPAD
.decode(b64.as_bytes())
.unwrap()
.map_err(|e| {
VeilidAPIError::generic(format!(
"error decoding base64url string '{}' into bytes: {}",
b64, e
))
})
}
pub fn marshall(data: &Vec<u8>) -> String {