File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818//! Utility library module for commonly used strings, hexadecimals and other elements.
1919
2020use crate :: jsonbuilder:: HEX ;
21- use std:: ffi:: CString ;
22- use std:: os:: raw:: c_char;
2321
2422pub mod nom7 {
2523 use nom7:: bytes:: streaming:: { tag, take_until} ;
@@ -101,32 +99,6 @@ pub mod nom8 {
10199 }
102100}
103101
104- /// Convert a String to C-compatible string
105- ///
106- /// This function will consume the provided data and use the underlying bytes to construct a new
107- /// string, ensuring that there is a trailing 0 byte. This trailing 0 byte will be appended by this
108- /// function; the provided data should *not* contain any 0 bytes in it.
109- ///
110- /// Returns a valid pointer, or NULL
111- pub fn rust_string_to_c ( s : String ) -> * mut c_char {
112- CString :: new ( s)
113- . map ( |c_str| c_str. into_raw ( ) )
114- . unwrap_or ( std:: ptr:: null_mut ( ) )
115- }
116-
117- /// Free a CString allocated by Rust (for ex. using `rust_string_to_c`)
118- ///
119- /// # Safety
120- ///
121- /// s must be allocated by rust, using `CString::new`
122- #[ no_mangle]
123- pub unsafe extern "C" fn SCRustCStringFree ( s : * mut c_char ) {
124- if s. is_null ( ) {
125- return ;
126- }
127- drop ( CString :: from_raw ( s) ) ;
128- }
129-
130102/// Convert an u8-array of data into a hexadecimal representation
131103pub fn to_hex ( input : & [ u8 ] ) -> String {
132104 return input
You can’t perform that action at this time.
0 commit comments