netscan_service/
result.rs1#[derive(Clone, Debug, PartialEq)]
3pub struct ServiceProbeResult {
4 pub port: u16,
5 pub service_name: String,
6 pub service_detail: Option<String>,
7 pub response: Vec<u8>,
8 pub error: Option<ServiceProbeError>,
9}
10
11impl ServiceProbeResult {
12 pub fn new(port: u16, service_name: String, response: Vec<u8>) -> Self {
14 ServiceProbeResult {
15 port,
16 service_name,
17 service_detail: None,
18 response,
19 error: None,
20 }
21 }
22
23 pub fn with_error(port: u16, service_name: String, error: ServiceProbeError) -> Self {
25 ServiceProbeResult {
26 port,
27 service_name,
28 service_detail: None,
29 response: Vec::new(),
30 error: Some(error),
31 }
32 }
33
34 pub fn has_error(&self) -> bool {
36 self.error.is_some()
37 }
38
39 pub fn error(&self) -> Option<&ServiceProbeError> {
41 self.error.as_ref()
42 }
43
44 pub fn into_error(self) -> Option<ServiceProbeError> {
46 self.error
47 }
48}
49
50#[derive(Clone, Debug, PartialEq)]
51pub enum ServiceProbeError {
52 ConnectionError(String),
53 WriteError(String),
54 ReadError(String),
55 TlsError(String),
56 CustomError(String),
57}