adapt windows + macos error types

This commit is contained in:
Ferdinand Schober
2024-06-28 23:31:42 +02:00
parent 16df8e9693
commit 1db43c4751
2 changed files with 27 additions and 3 deletions

View File

@@ -18,18 +18,29 @@ pub enum CaptureCreationError {
LayerShell(#[from] LayerShellCaptureCreationError), LayerShell(#[from] LayerShellCaptureCreationError),
#[cfg(all(unix, feature = "x11", not(target_os = "macos")))] #[cfg(all(unix, feature = "x11", not(target_os = "macos")))]
X11(#[from] X11InputCaptureCreationError), X11(#[from] X11InputCaptureCreationError),
#[cfg(target_os = "macos")]
Macos(#[from] MacOSInputCaptureCreationError),
#[cfg(windows)]
Windows,
} }
impl Display for CaptureCreationError { impl Display for CaptureCreationError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let reason = match self { let reason = match self {
#[cfg(all(unix, feature = "libei", not(target_os = "macos")))]
CaptureCreationError::Libei(reason) => { CaptureCreationError::Libei(reason) => {
format!("error creating portal backend: {reason}") format!("error creating portal backend: {reason}")
} }
#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))]
CaptureCreationError::LayerShell(reason) => { CaptureCreationError::LayerShell(reason) => {
format!("error creating layer-shell backend: {reason}") format!("error creating layer-shell backend: {reason}")
} }
#[cfg(all(unix, feature = "x11", not(target_os = "macos")))]
CaptureCreationError::X11(e) => format!("{e}"), CaptureCreationError::X11(e) => format!("{e}"),
#[cfg(target_os = "macos")]
CaptureCreationError::Macos(e) => format!("{e}"),
#[cfg(windows)]
CaptureCreationError::Windows => String::from(""),
}; };
write!(f, "could not create input capture: {reason}") write!(f, "could not create input capture: {reason}")
} }
@@ -115,3 +126,15 @@ impl Display for X11InputCaptureCreationError {
write!(f, "X11 input capture is not yet implemented :(") write!(f, "X11 input capture is not yet implemented :(")
} }
} }
#[cfg(target_os = "macos")]
#[derive(Debug, Error)]
pub enum MacOSInputCaptureCreationError {
NotImplemented,
}
#[cfg(target_os = "macos")]
impl Display for MacOSInputCaptureCreationError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "macos input capture is not yet implemented :(")
}
}

View File

@@ -1,16 +1,17 @@
use crate::capture::InputCapture; use crate::capture::InputCapture;
use crate::client::{ClientEvent, ClientHandle}; use crate::client::{ClientEvent, ClientHandle};
use crate::event::Event; use crate::event::Event;
use anyhow::{anyhow, Result}; use anyhow::Result;
use futures_core::Stream; use futures_core::Stream;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use std::{io, pin::Pin}; use std::{io, pin::Pin};
use crate::capture::error::MacOSInputCaptureCreationError;
pub struct MacOSInputCapture; pub struct MacOSInputCapture;
impl MacOSInputCapture { impl MacOSInputCapture {
pub fn new() -> Result<Self> { pub fn new() -> std::result::Result<Self, MacOSInputCaptureCreationError> {
Err(anyhow!("not yet implemented")) Err(MacOSInputCaptureCreationError::NotImplemented)
} }
} }