clay_layout/
id.rs

1use crate::{bindings::*, ElementConfigType, TypedConfig};
2
3pub struct Id;
4
5impl Id {
6    /// Creates a clay id using the `label`
7    #[allow(clippy::new_ret_no_self)]
8    pub fn new(label: &'static str) -> TypedConfig {
9        Self::new_index(label, 0)
10    }
11
12    /// Creates a clay id using the `label` and the `index`
13    pub fn new_index(label: &'static str, index: u32) -> TypedConfig {
14        Self::new_index_internal(label, index)
15    }
16
17    fn new_index_internal(label: &'static str, index: u32) -> TypedConfig {
18        let id = unsafe { Clay__HashString(label.into(), index, 0) };
19        TypedConfig {
20            config_memory: core::ptr::null_mut(),
21            id,
22            config_type: ElementConfigType::Id as _,
23        }
24    }
25}