use js_sys::{Function, Object, Promise, Uint8Array};
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
pub type SerialPort;
#[wasm_bindgen(method, catch)]
pub fn open(this: &SerialPort, options: &Object) -> Result<Promise, JsValue>;
#[wasm_bindgen(method, catch)]
pub fn close(this: &SerialPort) -> Result<Promise, JsValue>;
#[wasm_bindgen(method, catch, js_name = setSignals)]
pub fn set_signals(this: &SerialPort, signals: &Object) -> Result<Promise, JsValue>;
#[wasm_bindgen(method, catch, js_name = getInfo)]
pub fn get_info(this: &SerialPort) -> Result<JsValue, JsValue>;
#[wasm_bindgen(method, getter)]
pub fn readable(this: &SerialPort) -> JsValue;
#[wasm_bindgen(method, getter)]
pub fn writable(this: &SerialPort) -> JsValue;
pub type ReadableStream;
#[wasm_bindgen(method, catch, js_name = getReader)]
pub fn get_reader(this: &ReadableStream) -> Result<Reader, JsValue>;
pub type Reader;
#[wasm_bindgen(method, catch)]
pub fn read(this: &Reader) -> Result<Promise, JsValue>;
#[wasm_bindgen(method, catch)]
pub fn cancel(this: &Reader) -> Result<Promise, JsValue>;
#[wasm_bindgen(method, catch, js_name = releaseLock)]
pub fn release_lock(this: &Reader) -> Result<(), JsValue>;
pub type WritableStream;
#[wasm_bindgen(method, catch, js_name = getWriter)]
pub fn get_writer(this: &WritableStream) -> Result<Writer, JsValue>;
pub type Writer;
#[wasm_bindgen(method, catch)]
pub fn write(this: &Writer, chunk: &Uint8Array) -> Result<Promise, JsValue>;
#[wasm_bindgen(method, catch, js_name = releaseLock)]
pub fn release_lock(this: &Writer) -> Result<(), JsValue>;
#[wasm_bindgen(catch, js_namespace = ["navigator", "serial"], js_name = getPorts)]
pub fn get_ports() -> Result<Promise, JsValue>;
#[wasm_bindgen(js_name = setTimeout)]
pub fn set_timeout(handler: &Function, milliseconds: i32) -> JsValue;
#[wasm_bindgen(js_name = setTimeout)]
pub fn set_timeout_with(handler: &Function, milliseconds: i32, argument: &JsValue) -> JsValue;
#[wasm_bindgen(js_name = clearTimeout)]
pub fn clear_timeout(id: &JsValue);
#[wasm_bindgen(catch, js_name = String)]
pub fn string(value: &JsValue) -> Result<alloc::string::String, JsValue>;
}