from_c_str

Macro from_c_str 

Source
macro_rules! from_c_str {
    ($str:expr) => { ... };
}
Expand description

Converts a C string pointer to a Rust String.

This macro safely converts a raw C string pointer (*const c_char) into a Rust String. It handles UTF-8 conversion gracefully using lossy conversion.

§Safety

The pointer must be valid and point to a null-terminated C string.

§Examples

use osal_rs::from_c_str;
use core::ffi::c_char;
 
extern "C" {
    fn get_system_name() -> *const c_char;
}
 
let name = from_c_str!(get_system_name());
println!("System: {}", name);