1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use ash::vk;
use std::ffi::{CStr, CString};
pub mod debug_report;
pub mod device;
pub mod instance;
pub mod memory;
fn get_c_str_pointers(strs: &[CString]) -> Vec<*const i8> {
let mut ptrs = Vec::with_capacity(strs.len());
for layer in strs {
ptrs.push(layer.as_ptr());
}
ptrs
}
pub fn raw_name_to_c_string(raw: &mut [i8]) -> CString {
if raw.is_empty() {
return CString::new("").unwrap();
}
if let Some(last) = raw.last_mut() {
*last = 0
}
let c_str = unsafe { CStr::from_ptr(raw.as_ptr()) };
c_str.to_owned()
}
pub trait ContainRawVkName {
fn get_name(&mut self) -> &mut [i8];
fn c_string_name(&mut self) -> CString {
raw_name_to_c_string(self.get_name())
}
}
impl ContainRawVkName for vk::LayerProperties {
fn get_name(&mut self) -> &mut [i8] {
self.layer_name.as_mut()
}
}
impl ContainRawVkName for vk::ExtensionProperties {
fn get_name(&mut self) -> &mut [i8] {
self.extension_name.as_mut()
}
}