use crate::error::Error;
pub mod lib_executor;
#[cfg(any(test, feature = "test-utils"))]
pub mod mock;
#[async_trait::async_trait(?Send)]
pub trait JjExecutor: Send + Sync {
async fn is_repository(&self) -> Result<bool, Error>;
async fn describe(&self, revset: &str, message: &str) -> Result<(), Error>;
async fn get_description(&self, revset: &str) -> Result<String, Error>;
async fn new_revision(&self, revset: &str) -> Result<(), Error>;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn trait_definition_compiles() {
fn _accepts_executor<E: JjExecutor>(_executor: E) {}
fn _accepts_executor_ref<E: JjExecutor>(_executor: &E) {}
fn _accepts_executor_box(_executor: Box<dyn JjExecutor>) {}
}
#[test]
fn trait_is_object_safe() {
let _: Option<Box<dyn JjExecutor>> = None;
let _: Option<&dyn JjExecutor> = None;
}
#[test]
fn trait_requires_send_sync() {
fn _assert_send<T: Send>() {}
fn _assert_sync<T: Sync>() {}
_assert_send::<mock::MockJjExecutor>();
_assert_sync::<mock::MockJjExecutor>();
}
#[test]
fn mock_implements_trait() {
let mock = mock::MockJjExecutor::new();
fn _accepts_executor(_e: impl JjExecutor) {}
_accepts_executor(mock);
}
}