browser_commander/puppeteer/api/
writable_destination.rs1#![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 WritableDestination
15);
16
17impl WritableDestination {
18 pub async fn write(&self, chunk: &[u8]) -> Result<bool, BridgeError> {
24 self.remote.call("write", vec![Some(binary(chunk))]).await
25 }
26
27 pub async fn end(&self) -> Result<Value, BridgeError> {
33 self.remote.call("end", vec![]).await
34 }
35
36 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}