Skip to main content

browser_control/bidi/
protocol.rs

1//! WebDriver BiDi wire protocol types.
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Debug, Serialize)]
7pub struct Command<'a> {
8    pub id: u64,
9    pub method: &'a str,
10    pub params: Value,
11}
12
13#[derive(Debug, Deserialize)]
14#[serde(tag = "type", rename_all = "lowercase")]
15pub enum IncomingMessage {
16    Success {
17        id: u64,
18        #[serde(default)]
19        result: Value,
20    },
21    Error {
22        id: Option<u64>,
23        error: String,
24        message: String,
25    },
26    Event {
27        method: String,
28        #[serde(default)]
29        params: Value,
30    },
31}
32
33#[derive(Debug, thiserror::Error)]
34#[error("BiDi error {code}: {message}")]
35pub struct BidiError {
36    pub code: String,
37    pub message: String,
38}