Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/Common/ServiceInfo/
ServiceEndpoint.rs

1//! Network endpoint metadata: protocol, host, port, optional Unix-domain
2//! socket path. `NewUnix` is the convenience constructor for the
3//! UDS-only path; everything else uses the four-arg `new`.
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct Struct {
9	pub Protocol:String,
10
11	pub Address:String,
12
13	pub Port:u16,
14
15	pub Path:Option<String>,
16}
17
18impl Struct {
19	pub fn new(Protocol:impl Into<String>, Address:impl Into<String>, Port:u16) -> Self {
20		Self { Protocol:Protocol.into(), Address:Address.into(), Port, Path:None }
21	}
22
23	pub fn NewUnix(Path:impl Into<String>) -> Self {
24		Self {
25			Protocol:"unix".to_string(),
26
27			Address:String::new(),
28
29			Port:0,
30
31			Path:Some(Path.into()),
32		}
33	}
34}