Skip to main content

Module interface

Module interface 

Source
Expand description

Interface mode — Gradio-style fn → UI automatic generation.

Wraps a plain Rust function and automatically generates input/output widgets based on type inference. Inspired by Gradio’s gr.Interface(fn, inputs, outputs).

§Example

fn greet(name: String) -> String {
    format!("Hello, {}!", name)
}

fn main() {
    rustview::Interface::from_fn(greet)
        .title("Greeter")
        .description("Enter a name to greet.")
        .launch();
}

§Type Inference Rules

Rust TypeInput WidgetOutput Widget
Stringtext_inputwrite
f64number_inputmetric
f32number_inputmetric
i64int_inputmetric
boolcheckboxwrite
Vec<String>multi_selectjson
(A, B)two-field output

Structs§

Interface
The Interface builder — wraps a function and generates a complete UI.

Traits§

WidgetInput
Trait for types that can be automatically rendered as an input widget.
WidgetOutput
Trait for types that can be automatically rendered as an output widget.