Documentation

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

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

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

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

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

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

impl PsdkArgBase<Vec<u8>> for CVersion {
  fn header(&self) -> Vec<u8> {
    vec![0x10, 0xff, 0xef, 0xf1]
  }
  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>, CVersion, false);