use rand::Rng;
#[derive(Debug)]
pub(crate) struct ExecuteResponse {
pub(crate) response_id: i32,
pub(crate) response_type: i32,
pub(crate) response_body: String,
}
#[derive(Debug)]
pub struct AuthRequest {
pub id: usize,
pub request_type: u8,
pub password: String,
}
impl AuthRequest {
pub fn new(password: String) -> Self {
Self {
id: rand::thread_rng().gen::<usize>(),
request_type: 3,
password,
}
}
}
#[derive(Debug)]
pub struct AuthResponse {
pub id: isize,
pub response_type: u8,
}
impl AuthResponse {
pub fn is_success(&self) -> bool {
self.id != -1
}
}
#[derive(Debug)]
pub struct RCONRequest {
pub id: usize,
pub request_type: u8,
pub body: String,
}
impl RCONRequest {
pub fn new(body: String) -> Self {
Self {
id: rand::thread_rng().gen::<usize>(),
request_type: 2,
body,
}
}
}
#[derive(Debug)]
pub struct RCONResponse {
pub id: isize,
pub response_type: u8,
pub body: String,
}