Skip to main content

browser_commander/puppeteer/api/
file_chooser.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 `FileChooser` (puppeteer-core 25.10.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    FileChooser
15);
16
17impl FileChooser {
18    /// `FileChooser.isMultiple`
19    ///
20    /// ```text
21    /// isMultiple(): boolean
22    /// ```
23    pub async fn is_multiple(&self) -> Result<bool, BridgeError> {
24        self.remote.call("isMultiple", vec![]).await
25    }
26
27    /// `FileChooser.accept`
28    ///
29    /// ```text
30    /// accept(paths: string[]): Promise<void>
31    /// ```
32    pub async fn accept(&self, paths: &[&str]) -> Result<(), BridgeError> {
33        self.remote.call("accept", vec![Some(Value::Array(paths.iter().map(|v| Value::from(*v)).collect()))]).await
34    }
35
36    /// `FileChooser.cancel`
37    ///
38    /// ```text
39    /// cancel(): Promise<void>
40    /// ```
41    pub async fn cancel(&self) -> Result<(), BridgeError> {
42        self.remote.call("cancel", vec![]).await
43    }
44}