aither_agent/
browser_backend.rs1#[derive(Debug, Clone)]
5pub struct BrowserBackendError {
6 message: String,
7}
8
9impl BrowserBackendError {
10 #[must_use]
12 pub fn new(message: impl Into<String>) -> Self {
13 Self {
14 message: message.into(),
15 }
16 }
17}
18
19impl std::fmt::Display for BrowserBackendError {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 write!(f, "browser backend error: {}", self.message)
22 }
23}
24
25impl std::error::Error for BrowserBackendError {}
26
27pub trait BrowserBackend: Send + Sync {
32 fn cdp_endpoint(&self) -> impl Future<Output = Result<String, BrowserBackendError>> + Send;
34}
35
36#[derive(Debug, Clone)]
38pub struct StaticCdpBrowser {
39 endpoint: String,
40}
41
42impl StaticCdpBrowser {
43 #[must_use]
45 pub fn new(endpoint: impl Into<String>) -> Self {
46 Self {
47 endpoint: endpoint.into(),
48 }
49 }
50}
51
52impl BrowserBackend for StaticCdpBrowser {
53 fn cdp_endpoint(&self) -> impl Future<Output = Result<String, BrowserBackendError>> {
54 std::future::ready(Ok(self.endpoint.clone()))
55 }
56}