tokio_vsock/
tonic_support.rsuse tonic::transport::server::Connected;
use crate::{VsockAddr, VsockStream};
#[cfg_attr(docsrs, doc(cfg(feature = "tonic-conn")))]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct VsockConnectInfo {
peer_addr: Option<VsockAddr>,
}
#[cfg_attr(docsrs, doc(cfg(feature = "tonic-conn")))]
impl VsockConnectInfo {
pub fn peer_addr(&self) -> Option<VsockAddr> {
self.peer_addr
}
}
#[cfg_attr(docsrs, doc(cfg(feature = "tonic-conn")))]
impl Connected for VsockStream {
type ConnectInfo = VsockConnectInfo;
fn connect_info(&self) -> Self::ConnectInfo {
VsockConnectInfo {
peer_addr: self.peer_addr().ok(),
}
}
}