use crate::errors::PsdkFatherResult;

use super::{ConnectionState, DeviceWriteOptions, ReadOptions};

pub trait ConnectedDevice {
  fn device_name(&self) -> String;
  fn device_mac(&self) -> Option<String> {
    None
  }
  fn connection_state(&self) -> ConnectionState;
  fn disconnect(&self) -> PsdkFatherResult<()>;
  fn cancel_write(&self) -> PsdkFatherResult<bool> {
    Ok(false)
  }
  fn can_read(&self) -> bool;
  fn write(&self, binary: &[u8]) -> PsdkFatherResult<()>;
  fn write_with_options(
    &self,
    binary: &[u8],
    _options: DeviceWriteOptions,
  ) -> PsdkFatherResult<()> {
    self.write(binary)
  }
  fn read(&self, options: Option<ReadOptions>) -> PsdkFatherResult<Vec<u8>>;
  fn flush(&self) -> PsdkFatherResult<()>;
}
