use std::sync::{Arc, Mutex};

use psdk_father::{
  args::{ArgContext, PsdkArgBase, PsdkEasyArg},
  command::{CommandClause, PsdkBinaryCommand},
  errors::PsdkFatherResult,
};

#[derive(Clone, Debug)]
pub struct TStatus {
  ctx: Arc<Mutex<ArgContext>>,
}

impl Default for TStatus {
  fn default() -> Self {
    Self::new()
  }
}

impl TStatus {
  pub fn new() -> Self {
    Self {
      ctx: Default::default(),
    }
  }
}

impl PsdkEasyArg<Vec<u8>> for TStatus {
  fn context(&self) -> Arc<Mutex<ArgContext>> {
    self.ctx.clone()
  }
}

impl PsdkArgBase<Vec<u8>> for TStatus {
  fn header(&self) -> Vec<u8> {
    vec![0x1B, 0x21, 0x3F]
  }
  fn clause(&self) -> PsdkFatherResult<CommandClause> {
    let pbc = PsdkBinaryCommand::with_header(&self.header());
    Ok(pbc.clause())
  }
}

psdk_father::impl_psdk_arg_to_easy_arg!(Vec<u8>, TStatus, false);
