use std::fmt::Debug;
use async_trait::async_trait;
use peace_fmt::Presentable;
cfg_if::cfg_if! {
if #[cfg(feature = "output_progress")] {
use peace_progress_model::{
CmdBlockItemInteractionType,
ProgressTracker,
ProgressUpdateAndId,
};
use crate::CmdProgressTracker;
}
}
#[async_trait(?Send)]
pub trait OutputWrite: Debug + Unpin + 'static {
type Error: std::error::Error;
#[cfg(feature = "output_progress")]
async fn progress_begin(&mut self, cmd_progress_tracker: &CmdProgressTracker);
#[cfg(feature = "output_progress")]
async fn cmd_block_start(
&mut self,
cmd_block_item_interaction_type: CmdBlockItemInteractionType,
);
#[cfg(feature = "output_progress")]
async fn item_location_state(
&mut self,
item_id: peace_item_model::ItemId,
item_location_state: peace_item_interaction_model::ItemLocationState,
);
#[cfg(feature = "output_progress")]
async fn progress_update(
&mut self,
progress_tracker: &ProgressTracker,
progress_update_and_id: &ProgressUpdateAndId,
);
#[cfg(feature = "output_progress")]
async fn progress_end(&mut self, cmd_progress_tracker: &CmdProgressTracker);
async fn present<P>(&mut self, presentable: P) -> Result<(), Self::Error>
where
P: Presentable,
Self: Sized;
#[cfg(not(feature = "error_reporting"))]
async fn write_err<E>(&mut self, error: &E) -> Result<(), Self::Error>
where
E: std::error::Error;
#[cfg(feature = "error_reporting")]
async fn write_err<E>(&mut self, error: &E) -> Result<(), Self::Error>
where
E: miette::Diagnostic;
}