#[derive(Clone, Debug, PartialEq)]
pub struct ServiceProbeResult {
pub port: u16,
pub service_name: String,
pub service_detail: Option<String>,
pub response: Vec<u8>,
pub error: Option<ServiceProbeError>,
}
impl ServiceProbeResult {
pub fn new(port: u16, service_name: String, response: Vec<u8>) -> Self {
ServiceProbeResult {
port,
service_name,
service_detail: None,
response,
error: None,
}
}
pub fn with_error(port: u16, service_name: String, error: ServiceProbeError) -> Self {
ServiceProbeResult {
port,
service_name,
service_detail: None,
response: Vec::new(),
error: Some(error),
}
}
pub fn has_error(&self) -> bool {
self.error.is_some()
}
pub fn error(&self) -> Option<&ServiceProbeError> {
self.error.as_ref()
}
pub fn into_error(self) -> Option<ServiceProbeError> {
self.error
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum ServiceProbeError {
ConnectionError(String),
WriteError(String),
ReadError(String),
TlsError(String),
CustomError(String),
}