use serde::{Deserialize, Serialize};
use crate::transport::TransportTag;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Endpoint {
pub transport: TransportTag,
pub address: String,
}
impl Endpoint {
pub fn new(transport: TransportTag, address: impl Into<String>) -> Self {
Self { transport, address: address.into() }
}
pub fn tcp(address: impl Into<String>) -> Self {
Self::new(TransportTag::Tcp, address)
}
pub fn websocket(url: impl Into<String>) -> Self {
Self::new(TransportTag::WebSocket, url)
}
pub fn quic(address: impl Into<String>) -> Self {
Self::new(TransportTag::Quic, address)
}
pub fn uds(path: impl Into<String>) -> Self {
Self::new(TransportTag::Uds, path)
}
pub fn webtransport(url: impl Into<String>) -> Self {
Self::new(TransportTag::WebTransport, url)
}
pub fn stdio() -> Self {
Self::new(TransportTag::Stdio, String::new())
}
}