Skip to main content

ras_browser/domain/
repository.rs

1use std::path::PathBuf;
2
3use async_trait::async_trait;
4use ras_errors::AppError;
5use serde::{Deserialize, Serialize};
6use url::Url;
7
8use crate::domain::session::{BrowserSession, SessionState};
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11#[serde(tag = "kind", rename_all = "snake_case")]
12pub enum SessionMode {
13    Attach {
14        cdp_url: Url,
15    },
16    Launch {
17        binary: PathBuf,
18        port: Option<u16>,
19    },
20    Cloud {
21        api_key: String,
22        region: Option<String>,
23    },
24}
25
26#[async_trait]
27pub trait BrowserSessionPort: Send + Sync + 'static {
28    async fn start(&self, mode: SessionMode) -> Result<BrowserSession, AppError>;
29    async fn current_state(&self) -> Result<SessionState, AppError>;
30    async fn close(&self) -> Result<(), AppError>;
31}