photonic_interface_cli/
telnet.rs1use photonic::interface::{Interface, Introspection};
2use std::net::SocketAddr;
3use std::sync::Arc;
4use tokio::net::TcpListener;
5
6pub struct CLI {
7 pub address: SocketAddr,
8}
9
10impl Interface for CLI {
11 async fn listen(self, introspection: Arc<Introspection>) -> anyhow::Result<()> {
12 let listener = TcpListener::bind(&self.address).await?;
13
14 loop {
15 let introspection = introspection.clone();
16
17 let (mut stream, _remote) = listener.accept().await?;
18
19 tokio::spawn(async move {
20 let (i, o) = stream.split();
21 super::run(i, o, introspection).await
22 });
23 }
24 }
25}