declare module rust_native_module {
    type Result<T> =
        { type: "success", value: T }
        | { type: "error", message: string };

    type Option<T> =
        { type: "some", value: T }
        | { type: "none" }

    type Brightness =
        { type: "off" }
        | { type: "switch" }
        | { type: "dimmer", value: number }
        | { type: "strobe", value: number };

    type MovingHeadState = {
        startAddress: number, // [0, 512]

        pan: number, // [-3pi/2, 3pi/2]
        tilt: number, // [-pi/2, pi/2]
        brightness: Brightness,
        rgbw: [number, number, number, number], // RGBW, [0, 255]
        speed: number, // [0, 1]

        reset: boolean,
    }

    type OutputHandle = {
        set: (heads: Array<MovingHeadState>) => Result<never>,
        close: () => Result<never>,
    }

    type BeatTrackerHandle = {
        tap: () => void,
        getProgress: () => Option<number>,
    }

    function listPorts(): Array<string>;
    function openOutput(port: string): Result<OutputHandle>;

    function getBeatTracker(): Result<BeatTrackerHandle>;
}

export = rust_native_module;