use serde::{Deserialize, Serialize};
use std::fmt::{Debug, Display, Formatter};
use serde::de::DeserializeOwned;
pub mod security;
pub mod record;
pub mod system;
#[derive(Debug, Clone, Deserialize)]
pub struct SimpleResult {
#[serde(rename = "rspCode")]
pub rsp_code: isize
}
pub type NotApplicable = Option<()>;
pub trait JsonEndpoint : Serialize + Debug {
const CMD: &'static str;
const AUTH: AuthenticationType = AuthenticationType::LoginPassword;
type Response: DeserializeOwned;
type Initial: DeserializeOwned;
type Range: DeserializeOwned;
}
pub trait BinaryEndpoint : Serialize + Debug {
const CMD: &'static str;
const AUTH: AuthenticationType = AuthenticationType::LoginPassword;
}
#[derive(Debug, PartialEq, Eq)]
pub enum AuthenticationType {
None,
LoginPassword,
Token,
}
#[derive(Debug, Deserialize)]
pub struct ApiError {
pub code: isize,
pub error: ApiErrorData,
}
impl Display for ApiError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{} ({})", &self.error.detail, self.error.rsp_code)
}
}
impl std::error::Error for ApiError {}
#[derive(Debug, Deserialize)]
pub struct ApiErrorData {
#[serde(rename = "rspCode")]
pub rsp_code: isize,
pub detail: String,
}