feat(build): type generated event constants
Generate EventName constants for data-slhx-on metadata and exercise them through typed event emission in techdemo. req: codegen/006
This commit is contained in:
@@ -186,6 +186,41 @@ impl core::fmt::Display for CssClass {
|
||||
}
|
||||
}
|
||||
|
||||
/// A generated, checked event token.
|
||||
/// req: codegen/006
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct EventName {
|
||||
name: &'static str,
|
||||
}
|
||||
|
||||
impl EventName {
|
||||
pub const fn new(name: &'static str) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
pub const fn as_str(self) -> &'static str {
|
||||
self.name
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for EventName {
|
||||
fn as_ref(&self) -> &str {
|
||||
self.name
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EventName> for String {
|
||||
fn from(event: EventName) -> Self {
|
||||
event.name.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Display for EventName {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.write_str(self.name)
|
||||
}
|
||||
}
|
||||
|
||||
/// A small displayable list of generated CSS class tokens for hemplate `+class`.
|
||||
/// req: style/003
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
|
||||
|
||||
Reference in New Issue
Block a user