1use serde::{Deserialize, Serialize};
9
10use crate::transport::TransportTag;
11
12#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
21pub struct Endpoint {
22 pub transport: TransportTag,
23 pub address: String,
24}
25
26impl Endpoint {
27 pub fn new(transport: TransportTag, address: impl Into<String>) -> Self {
28 Self { transport, address: address.into() }
29 }
30
31 pub fn tcp(address: impl Into<String>) -> Self {
32 Self::new(TransportTag::Tcp, address)
33 }
34
35 pub fn websocket(url: impl Into<String>) -> Self {
36 Self::new(TransportTag::WebSocket, url)
37 }
38
39 pub fn quic(address: impl Into<String>) -> Self {
40 Self::new(TransportTag::Quic, address)
41 }
42
43 pub fn uds(path: impl Into<String>) -> Self {
44 Self::new(TransportTag::Uds, path)
45 }
46
47 pub fn webtransport(url: impl Into<String>) -> Self {
48 Self::new(TransportTag::WebTransport, url)
49 }
50
51 pub fn stdio() -> Self {
52 Self::new(TransportTag::Stdio, String::new())
53 }
54}