#[repr(C)]pub struct ComponentDef {
pub id: ComponentId,
pub display_name: AzString,
pub description: AzString,
pub css: AzString,
pub source: ComponentSource,
pub data_model: ComponentDataModel,
pub render_fn: fn(&ComponentDef, &ComponentDataModel, &ComponentMap) -> ResultStyledDomRenderDomError,
pub compile_fn: fn(&ComponentDef, &CompileTarget, &ComponentDataModel, usize) -> ResultStringCompileError,
pub render_fn_source: OptionString,
pub compile_fn_source: OptionString,
}Expand description
A component definition — the “class” / “template” of a component. Can come from Rust builtins, compiled widgets, JSON, or user creation in debugger.
Fields§
§id: ComponentIdCollection + name, e.g. builtin:div, shadcn:avatar
display_name: AzStringHuman-readable display name, e.g. “Link” for builtin:a, “Avatar” for shadcn:avatar
description: AzStringMarkdown documentation for the component
css: AzStringThe component’s CSS
source: ComponentSourceWhere this component was defined (determines exportability)
data_model: ComponentDataModelUnified data model: all value fields, callback slots, and child slots
in a single named struct. Code gen uses data_model.name as the
input struct type name (e.g. “ButtonData”).
The default_value on each field doubles as the “current value” for
preview rendering — callers override defaults before calling render_fn.
render_fn: fn(&ComponentDef, &ComponentDataModel, &ComponentMap) -> ResultStyledDomRenderDomErrorRender to live DOM
compile_fn: fn(&ComponentDef, &CompileTarget, &ComponentDataModel, usize) -> ResultStringCompileErrorCompile to source code in target language
render_fn_source: OptionStringSource code for render_fn (user-defined components only)
compile_fn_source: OptionStringSource code for compile_fn (user-defined components only)
Trait Implementations§
Source§impl Clone for ComponentDef
impl Clone for ComponentDef
Source§fn clone(&self) -> ComponentDef
fn clone(&self) -> ComponentDef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ComponentDef
impl Debug for ComponentDef
Source§impl Extend<ComponentDef> for ComponentDefVec
impl Extend<ComponentDef> for ComponentDefVec
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = ComponentDef>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = ComponentDef>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<ComponentDef> for ComponentDefVec
impl FromIterator<ComponentDef> for ComponentDefVec
Source§fn from_iter<T>(iter: T) -> ComponentDefVecwhere
T: IntoIterator<Item = ComponentDef>,
fn from_iter<T>(iter: T) -> ComponentDefVecwhere
T: IntoIterator<Item = ComponentDef>,
Auto Trait Implementations§
impl Freeze for ComponentDef
impl RefUnwindSafe for ComponentDef
impl Send for ComponentDef
impl Sync for ComponentDef
impl Unpin for ComponentDef
impl UnsafeUnpin for ComponentDef
impl UnwindSafe for ComponentDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more