@@ -416,6 +416,39 @@ where
416416}
417417
418418/// Bind to a service binding listener.
419+ ///
420+ /// # Examples
421+ ///
422+ /// The following example uses `clap` to parse the host socket data
423+ /// thus allowing the user to choose at runtime whether they want to
424+ /// use TCP sockets, Unix domain sockets (including systemd socket
425+ /// activation) or Named Pipes (under Windows).
426+ ///
427+ /// ```no_run
428+ /// use clap::Parser;
429+ /// use service_binding::Binding;
430+ /// use ssh_agent_lib::agent::{bind, Session};
431+ ///
432+ /// #[derive(Debug, Parser)]
433+ /// struct Args {
434+ /// #[clap(long, short = 'H', default_value = "unix:///tmp/ssh.sock")]
435+ /// host: Binding,
436+ /// }
437+ ///
438+ /// #[derive(Default, Clone)]
439+ /// struct MyAgent;
440+ ///
441+ /// impl Session for MyAgent {}
442+ ///
443+ /// #[tokio::main]
444+ /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
445+ /// let args = Args::parse();
446+ ///
447+ /// bind(args.host.try_into()?, MyAgent::default()).await?;
448+ ///
449+ /// Ok(())
450+ /// }
451+ /// ```
419452#[ cfg( unix) ]
420453pub async fn bind < A > ( listener : service_binding:: Listener , agent : A ) -> Result < ( ) , AgentError >
421454where
@@ -436,6 +469,39 @@ where
436469}
437470
438471/// Bind to a service binding listener.
472+ ///
473+ /// # Examples
474+ ///
475+ /// The following example uses `clap` to parse the host socket data
476+ /// thus allowing the user to choose at runtime whether they want to
477+ /// use TCP sockets, Unix domain sockets (including systemd socket
478+ /// activation) or Named Pipes (under Windows).
479+ ///
480+ /// ```no_run
481+ /// use clap::Parser;
482+ /// use service_binding::Binding;
483+ /// use ssh_agent_lib::agent::{bind, Session};
484+ ///
485+ /// #[derive(Debug, Parser)]
486+ /// struct Args {
487+ /// #[clap(long, short = 'H', default_value = "unix:///tmp/ssh.sock")]
488+ /// host: Binding,
489+ /// }
490+ ///
491+ /// #[derive(Default, Clone)]
492+ /// struct MyAgent;
493+ ///
494+ /// impl Session for MyAgent {}
495+ ///
496+ /// #[tokio::main]
497+ /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
498+ /// let args = Args::parse();
499+ ///
500+ /// bind(args.host.try_into()?, MyAgent::default()).await?;
501+ ///
502+ /// Ok(())
503+ /// }
504+ /// ```
439505#[ cfg( windows) ]
440506pub async fn bind < A > ( listener : service_binding:: Listener , agent : A ) -> Result < ( ) , AgentError >
441507where
0 commit comments