Skip to main content

browser_commander/puppeteer/api/
writable_destination.rs

1// @generated by scripts/generate-puppeteer-bindings.mjs from
2// rust/protocol/puppeteer/api.json. Do not edit by hand.
3
4#![allow(clippy::all, missing_docs, unused_imports, non_snake_case)]
5
6use serde_json::Value;
7
8use super::*;
9use crate::puppeteer::bridge::{binary, remote_type, BridgeError, JsFunction, Remote};
10
11remote_type!(
12    /// Puppeteer's `WritableDestination` (puppeteer-core 25.10.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    WritableDestination
15);
16
17impl WritableDestination {
18    /// `WritableDestination.write`
19    ///
20    /// ```text
21    /// write(chunk: Uint8Array): boolean
22    /// ```
23    pub async fn write(&self, chunk: &[u8]) -> Result<bool, BridgeError> {
24        self.remote.call("write", vec![Some(binary(chunk))]).await
25    }
26
27    /// `WritableDestination.end`
28    ///
29    /// ```text
30    /// end(): unknown
31    /// ```
32    pub async fn end(&self) -> Result<Value, BridgeError> {
33        self.remote.call("end", vec![]).await
34    }
35
36    /// `WritableDestination.once`
37    ///
38    /// ```text
39    /// once?(event: string, cb: (arg?: unknown) => void): unknown
40    /// ```
41    pub async fn once(&self, event: &str, cb: impl Into<JsFunction>) -> Result<Value, BridgeError> {
42        self.remote.call("once", vec![Some(Value::from(event)), Some(cb.into().to_wire())]).await
43    }
44}