buni-rs 1.2.0

Reference Buni serializer / deserializer in Rust
Documentation
use alloc::format;
use alloc::string::{String, ToString};

pub const SPECIAL_CHARACTERS: &str = "()\":";

pub fn escape_buni(str: &str) -> String {
    if numerical(str)
        || str.contains(|c| {
        SPECIAL_CHARACTERS.contains(c)
    })
        || str == "True"
        || str == "true"
        || str == "False"
        || str == "false"
        || str == "None"
        || str == "none"
    {
        format!("\"{}\"", str)
    } else {
        str.to_string()
    }
}

pub fn numerical(str: &str) -> bool {
    for char in str.chars() {
        if !char.is_numeric() {
            return false;
        }
    }
    true
}