File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,31 @@ where
261
261
262
262
/// Listen for connections on a given socket and use session factory
263
263
/// to create new session for each accepted socket.
264
+ ///
265
+ /// # Examples
266
+ ///
267
+ /// The following example starts listening for connections and
268
+ /// processes them with the `MyAgent` struct.
269
+ ///
270
+ /// ```no_run
271
+ /// # async fn main_() -> testresult::TestResult {
272
+ /// use ssh_agent_lib::agent::{listen, Session};
273
+ /// use tokio::net::TcpListener;
274
+ ///
275
+ /// #[derive(Default, Clone)]
276
+ /// struct MyAgent;
277
+ ///
278
+ /// impl Session for MyAgent {
279
+ /// // implement your agent logic here
280
+ /// }
281
+ ///
282
+ /// listen(
283
+ /// TcpListener::bind("127.0.0.1:8080").await?,
284
+ /// MyAgent::default(),
285
+ /// )
286
+ /// .await?;
287
+ /// # Ok(()) }
288
+ /// ```
264
289
pub async fn listen < S > ( mut socket : S , mut sf : impl Agent < S > ) -> Result < ( ) , AgentError >
265
290
where
266
291
S : ListeningSocket + fmt:: Debug + Send ,
You can’t perform that action at this time.
0 commit comments