use thiserror::Error;
use crate::{update_source::UpdateInfo, update_workflow::UpdateError};
#[derive(Debug, Error)]
pub enum ConsentHandlerError {
#[error("Consent handler error: {0}")]
Error(String),
}
pub trait ConsentHandler {
fn ask_for_consent(
&mut self,
update_info: &impl UpdateInfo,
) -> impl std::future::Future<Output = Result<bool, UpdateError>>;
}
pub struct AutoConsent {
pub consent: bool,
}
impl AutoConsent {
pub fn new(consent: bool) -> Self {
Self { consent }
}
}
impl ConsentHandler for AutoConsent {
async fn ask_for_consent(
&mut self,
_update_info: &impl UpdateInfo,
) -> Result<bool, UpdateError> {
Ok(self.consent)
}
}