codama_nodes/shared/
bytes_encoding.rs1use crate::BytesEncoding;
2use codama_errors::{CodamaError, CodamaResult};
3pub use BytesEncoding::*;
4
5impl TryFrom<String> for BytesEncoding {
6 type Error = CodamaError;
7
8 fn try_from(value: String) -> CodamaResult<Self> {
9 value.as_str().try_into()
10 }
11}
12
13impl TryFrom<&str> for BytesEncoding {
14 type Error = CodamaError;
15
16 fn try_from(value: &str) -> CodamaResult<Self> {
17 match value {
18 "base16" => Ok(Base16),
19 "base58" => Ok(Base58),
20 "base64" => Ok(Base64),
21 "utf8" => Ok(Utf8),
22 _ => Err(CodamaError::InvalidBytesEncoding(value.to_string())),
23 }
24 }
25}