originv0.2.0

← All examples

Rust type to TypeScript binding

PulseSnapshot is what the demo’s UI renders. Its TypeScript type in src/pulse.generated.ts is derived from the Rust struct with ts-rs, and a test fails when the checked-in file drifts.

Rust type to TypeScript binding

examples/demo/src-tauri/src/pulse.rs
#[derive(Debug, Clone, Serialize, ts_rs::TS)]
pub struct PulseSnapshot {
    pub health: Health,
    pub metric: Option<Metric>,
    pub alerts: Vec<Alert>,
}
// Generated from PulseSnapshot in src-tauri/src/pulse.rs. Do not edit.

import type { Alert, Health, Metric } from "@casoon/origin-client";

export type PulseSnapshot = { health: Health, metric: Metric | null, alerts: Array<Alert>, };
  • ts-rs
  • IPC contract
  • cargo test