browser-commander 0.19.0

Universal browser automation library that supports multiple browser engines with a unified API
Documentation
// @generated by scripts/generate-puppeteer-bindings.mjs from
// rust/protocol/puppeteer/api.json. Do not edit by hand.

#![allow(clippy::all, missing_docs, unused_imports, non_snake_case)]

use serde_json::Value;

use super::*;
use crate::puppeteer::bridge::{binary, remote_type, BridgeError, JsFunction, Remote};

remote_type!(
    /// Puppeteer's `WritableDestination` (puppeteer-core 25.12.0), a remote object
    /// served by `browser-commander serve --stdio`.
    WritableDestination
);

impl WritableDestination {
    /// `WritableDestination.write`
    ///
    /// ```text
    /// write(chunk: Uint8Array): boolean
    /// ```
    pub async fn write(&self, chunk: &[u8]) -> Result<bool, BridgeError> {
        self.remote.call("write", vec![Some(binary(chunk))]).await
    }

    /// `WritableDestination.end`
    ///
    /// ```text
    /// end(): unknown
    /// ```
    pub async fn end(&self) -> Result<Value, BridgeError> {
        self.remote.call("end", vec![]).await
    }

    /// `WritableDestination.once`
    ///
    /// ```text
    /// once?(event: string, cb: (arg?: unknown) => void): unknown
    /// ```
    pub async fn once(&self, event: &str, cb: impl Into<JsFunction>) -> Result<Value, BridgeError> {
        self.remote.call("once", vec![Some(Value::from(event)), Some(cb.into().to_wire())]).await
    }
}