dfns_sdk_rs/utils/
string.rs

1// @dfns-sdk-rs/src/utils/string.rs
2
3pub fn split_string(text: &str, max_line_length: Option<usize>) -> Vec<String> {
4    let length = max_line_length.unwrap_or(64);
5    if text.is_empty() {
6        return Vec::new();
7    }
8
9    let chars: Vec<char> = text.chars().collect();
10    chars
11        .chunks(length)
12        .map(|chunk| chunk.iter().collect::<String>())
13        .collect()
14}
15
16pub fn to_hex(buffer: &[u8]) -> String {
17    buffer
18        .iter()
19        .map(|byte| format!("{:02x}", byte))
20        .collect::<String>()
21}