Skip to main content

Mountain/IPC/Common/ServiceInfo/
ServiceEndpoint.rs

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