Skip to main content

lgui_core/window/
id.rs

1#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2pub struct WindowId(String);
3
4impl WindowId {
5    pub fn new(value: impl Into<String>) -> Self {
6        let value = value.into();
7        assert!(!value.trim().is_empty(), "window id must not be empty");
8        Self(value)
9    }
10
11    pub fn as_str(&self) -> &str {
12        &self.0
13    }
14}
15
16impl From<&str> for WindowId {
17    fn from(value: &str) -> Self {
18        Self::new(value)
19    }
20}
21
22impl From<String> for WindowId {
23    fn from(value: String) -> Self {
24        Self::new(value)
25    }
26}