5个不稳定版本
0.3.1 | 2023年6月6日 |
---|---|
0.3.0 | 2023年6月6日 |
0.1.2 | 2023年6月6日 |
0.1.1 | 2023年2月16日 |
0.0.0 | 2022年11月14日 |
#1307 在 过程宏
每月64次下载
在 debridge-solana-sdk 中使用
11KB
117 行
Env To Array
此库允许您从编码字符串常量创建常量数组,也可以直接从环境变量中获取它们。
安装
cargo add env-to-array
用法
从环境变量字符串获取,解码它并作为整数数组输出
base58
应启用 bs58
功能(默认启用)
/// Get array from env variable encoded by base58
const BS58_ENV_ID: [u8; 17] = env_to_array::bs58_env_to_array!("_ENV_TO_ARRAY_BS58");
/// Get array from constant encoded by base58
const BS58_ID: [u8; 17] = env_to_array::bs58_to_array!("dwVAPpaonY26V6JH17ToUQ");
base64
应启用 bs64
功能(默认启用)
/// Get array from env variable encoded by base64
const BS64_ENV_ID: [u8; 32] = env_to_array::bs64_env_to_array!("_ENV_TO_ARRAY_BS64");
/// Get array from constant encoded by base64
const BS64_ID: [u8; 32] = env_to_array::bs64_to_array!("W7MmhbfqLQc4LbN0TUPfiflxSO6uVZ7E0NH+76LueJ0=");
hex
应启用 hex
功能(默认启用)
/// Get array from env variable encoded by hex
const HEX_ENV_ID: [u64; 64] = env_to_array::hex_env_to_array!("_ENV_TO_ARRAY_HEX");
/// Get array from constant encoded by hex
const HEX_ID: [u64; 64] = env_to_array::hex_to_array!("5bb32685b7e5bb32685b7ea2d07382db3744d43df89f97148eeae559ec4d0d1feefa2ee789da2d07382db3744d43df89f97148eeae559ec4d0d1feefa2ee789d");
base32
应启用 bs32
功能(默认启用)
/// Get array from env variable encoded by base58
const BS32_ENV_ID: [u8; 5] = env_to_array::bs32_env_to_array!("_ENV_TO_ARRAY_BS32");
/// Get array from constant encoded by base58
const BS32_ID: [u8; 5] = env_to_array::bs32_to_array!("Z0Z0Z0Z0");
base85
应启用 bs85
功能(默认启用)
/// Get array from env variable encoded by base58
const BS85_ENV_ID: [u8; 5] = env_to_array::bs32_env_to_array!("_ENV_TO_ARRAY_BS85");
/// Get array from constant encoded by base58
const BS85_ID: [u8; 5] = env_to_array::bs32_to_array!("VPRomVPRn");
依赖
~2MB
~46K SLoC