pub trait FromInputs: Sized {
type Inputs;
type Error;
// Required method
fn from_inputs(
inputs: Self::Inputs,
owner: OwnerHandle,
) -> Result<Self, Self::Error>;
}Expand description
The explicit input contract for compiler-resolved component tags.
Inputs is a named-field struct (or a unit struct for empty tags). The
compiler builds it with an ordinary struct literal: rustc checks every field,
its visibility, and its type. Input expressions and this constructor run once
per mounted identity, untracked. Pass signals or memos for live shared inputs.
Construction is separate from rendering: browser mounts require Component.
owner is the new child’s prepared owner. The caller owns preparation,
activation, rollback, and conversion of construction errors. This trait does
not itself defer ordinary effects or activate the owner.
Simple concrete components can use #[derive(fusor::FromInputs)]:
mark every field #[input] (required from the parent) or
#[local(init = expression)] (initialized once per instance). The derive
generates a TypeNameInputs struct with the component’s visibility and
public input fields, plus this trait implementation. Original field
visibility is unchanged. Unit and all-local components get unit Inputs.
Local expressions execute in declaration order in the generated constructor;
Self refers to the component. They have no implicit inputs/owner names
and cannot access other instance fields. Implement this trait manually for
input-dependent initialization, owner-aware setup, or generic components.
The derive creates neither a new method nor a template association.
Use #[from_inputs(crate = ::alias)] when renaming the runtime dependency.
Enable the derive feature to use the derive without any browser dependencies;
dom also enables it. The derived error type is std::convert::Infallible.
§Migrating manual implementations
Existing browser implementations add type Error = fusor::dom::JsValue; and
keep their return signature. fusor::dom::FromInputs is this same trait.
Portable implementations choose their own error type. Browser mounting uses
fusor::dom::IntoMountError: it preserves JsValue and supports Infallible,
String, and &str. Implement it for custom browser errors; there is no
blanket Display conversion.
Required Associated Types§
Required Methods§
fn from_inputs( inputs: Self::Inputs, owner: OwnerHandle, ) -> Result<Self, Self::Error>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".