File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,39 @@ use crate::proto::SignRequest;
3434use crate :: proto:: SmartcardKey ;
3535
3636/// Type representing a socket that asynchronously returns a list of streams.
37+ ///
38+ /// This trait is implemented for [TCP sockets](TcpListener) on all
39+ /// platforms, Unix sockets on Unix platforms (e.g. Linux, macOS) and
40+ /// Named Pipes on Windows.
41+ ///
42+ /// Objects implementing this trait are passed to the [`listen`]
43+ /// function.
44+ ///
45+ /// # Examples
46+ ///
47+ /// The following example starts listening for connections and
48+ /// processes them with the `MyAgent` struct.
49+ ///
50+ /// ```no_run
51+ /// # async fn main_() -> testresult::TestResult {
52+ /// use ssh_agent_lib::agent::{listen, Session};
53+ /// use tokio::net::TcpListener;
54+ ///
55+ /// #[derive(Default, Clone)]
56+ /// struct MyAgent;
57+ ///
58+ /// impl Session for MyAgent {
59+ /// // implement your agent logic here
60+ /// }
61+ ///
62+ /// listen(
63+ /// TcpListener::bind("127.0.0.1:8080").await?,
64+ /// MyAgent::default(),
65+ /// )
66+ /// .await?;
67+ /// # Ok(()) }
68+ /// ```
69+
3770#[ async_trait]
3871pub trait ListeningSocket {
3972 /// Stream type that represents an accepted socket.
You can’t perform that action at this time.
0 commit comments