#env-var #array #variables #constant #encoded-string #string-literal #hex

env_to_array

从字符串常量和环境变量中收集不同编码数组的辅助库

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过程宏

Download history 23/week @ 2024-03-09 40/week @ 2024-03-16 174/week @ 2024-03-23 52/week @ 2024-03-30 53/week @ 2024-04-06 113/week @ 2024-04-13 14/week @ 2024-04-20 74/week @ 2024-05-04 2/week @ 2024-05-11 26/week @ 2024-05-18 21/week @ 2024-05-25 35/week @ 2024-06-01 18/week @ 2024-06-08 2/week @ 2024-06-15 2/week @ 2024-06-22

每月64次下载
debridge-solana-sdk 中使用

MIT 许可证

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