Function listen

Source
pub async fn listen<S>(
    socket: S,
    agent: impl Agent<S>,
) -> Result<(), AgentError>
where S: ListeningSocket + Debug + Send,
Expand description

Listen for connections on a given socket and use session factory to create new session for each accepted socket.

ยงExamples

The following example starts listening for connections and processes them with the MyAgent struct.

use ssh_agent_lib::agent::{listen, Session};
use tokio::net::TcpListener;

#[derive(Default, Clone)]
struct MyAgent;

impl Session for MyAgent {
    // implement your agent logic here
}

listen(
    TcpListener::bind("127.0.0.1:8080").await?,
    MyAgent::default(),
)
.await?;