Skip to main content

interstice_sdk/
lib.rs

1pub mod bindings;
2pub mod macros;
3
4pub use interstice_abi;
5pub use interstice_abi::*;
6pub use interstice_sdk_core::*;
7pub use interstice_sdk_macros::*;
8pub use std::str::FromStr;
9
10pub fn to_snake_case(name: &str) -> String {
11    name.trim().to_lowercase().replace("-", "_")
12}
13
14pub fn snake_to_camel_case(name: &str) -> String {
15    let node_type_str =
16        name.chars().nth(0).unwrap().to_uppercase().to_string() + &name[1..name.len()];
17    // Remove "_" and add uppercase to the following character
18    node_type_str
19        .split('_')
20        .map(|s| {
21            let mut chars = s.chars();
22            match chars.next() {
23                None => String::new(),
24                Some(f) => f.to_uppercase().to_string() + chars.as_str(),
25            }
26        })
27        .collect::<String>()
28}