synd_term/interact/
mod.rs1use std::{io, path::PathBuf};
2
3#[cfg(feature = "integration")]
4pub mod mock;
5mod process;
6pub use process::{ProcessInteractor, TextBrowserInteractor};
7
8use thiserror::Error;
9use url::Url;
10
11pub trait Interact: OpenWebBrowser + OpenTextBrowser + OpenEditor {}
12
13#[derive(Debug, Error)]
14pub enum OpenBrowserError {
15 #[error("io: {0}")]
16 Io(#[from] io::Error),
17 #[error("command `{command}` not found")]
18 CommandNotFound { command: PathBuf },
19}
20
21pub trait OpenWebBrowser {
22 fn open_browser(&self, url: Url) -> Result<(), OpenBrowserError>;
23}
24
25pub trait OpenTextBrowser {
26 fn open_text_browser(&self, url: Url) -> Result<(), OpenBrowserError>;
27}
28
29#[derive(Debug, Error)]
30#[error("failed to open editor: {message}")]
31pub struct OpenEditorError {
32 message: String,
33}
34
35pub trait OpenEditor {
36 fn open_editor(&self, initial_content: &str) -> Result<String, OpenEditorError>;
37}