use rustecal_core::types::EntityId;
use rustecal_sys::*;
use std::ffi::CStr;
#[derive(Debug, Clone)]
pub struct TopicId {
pub entity_id: EntityId,
pub topic_name: String,
}
impl From<eCAL_STopicId> for TopicId {
fn from(raw: eCAL_STopicId) -> Self {
Self {
entity_id: EntityId::from(raw.topic_id),
topic_name: cstr_to_string(raw.topic_name),
}
}
}
fn cstr_to_string(ptr: *const std::os::raw::c_char) -> String {
if ptr.is_null() {
String::new()
} else {
unsafe { CStr::from_ptr(ptr).to_string_lossy().into_owned() }
}
}