chrome_for_testing_manager/
session.rs1use thiserror::Error;
2
3#[derive(Debug)]
8pub struct Session {
9 #[cfg(feature = "thirtyfour")]
10 pub(crate) driver: thirtyfour::WebDriver,
11}
12
13#[derive(Debug, Error)]
14pub enum SessionError {
15 #[error("The user code panicked:\n{reason}")]
16 Panic { reason: String },
17
18 #[cfg(feature = "thirtyfour")]
19 #[error("thirtyfour WebDriverError")]
20 Thirtyfour {
21 #[from]
22 source: thirtyfour::error::WebDriverError,
23 },
24}
25
26impl Session {
27 pub async fn quit(self) -> Result<(), SessionError> {
33 #[cfg(feature = "thirtyfour")]
34 {
35 self.driver.quit().await.map_err(Into::into)
36 }
37
38 #[cfg(not(feature = "thirtyfour"))]
39 {
40 Ok(())
41 }
42 }
43}
44
45#[cfg(feature = "thirtyfour")]
46impl std::ops::Deref for Session {
47 type Target = thirtyfour::WebDriver;
48
49 fn deref(&self) -> &Self::Target {
50 &self.driver
51 }
52}