Crate openkit_macros

Crate openkit_macros 

Source
Expand description

Procedural macros for the OpenKit UI framework.

This crate provides derive macros and attribute macros for building OpenKit applications with less boilerplate.

§Macros

  • Widget - Derive macro for implementing the Widget trait
  • Component - Derive macro for creating Angular-like components
  • Styleable - Derive macro for CSS styling support
  • [#[component]] - Attribute macro for component definitions
  • [#[prop]] - Attribute macro for component properties
  • [#[state]] - Attribute macro for component state
  • [#[event]] - Attribute macro for event emitters

§Examples

use openkit::prelude::*;
use openkit_macros::{Widget, Component, Styleable};

#[derive(Widget, Styleable)]
struct MyWidget {
    #[base]
    base: WidgetBase,
    label: String,
}

#[derive(Component)]
#[component(selector = "my-counter")]
struct CounterComponent {
    #[state]
    count: i32,

    #[prop(default = 1)]
    step: i32,

    #[event]
    on_change: EventEmitter<i32>,
}

Attribute Macros§

component
Attribute macro for defining components with inline render function.
event
Attribute macro for marking event emitters.
prop
Attribute macro for marking component properties.
state
Attribute macro for marking component state.

Derive Macros§

Component
Derive macro for creating Angular-like components.
Styleable
Derive macro for CSS styling support.
Widget
Derive macro for implementing the Widget trait.