Function bind

Source
pub async fn bind<A>(listener: Listener, agent: A) -> Result<(), AgentError>
Expand description

Bind to a service binding listener.

ยงExamples

The following example uses clap to parse the host socket data thus allowing the user to choose at runtime whether they want to use TCP sockets, Unix domain sockets (including systemd socket activation) or Named Pipes (under Windows).

use clap::Parser;
use service_binding::Binding;
use ssh_agent_lib::agent::{bind, Session};

#[derive(Debug, Parser)]
struct Args {
    #[clap(long, short = 'H', default_value = "unix:///tmp/ssh.sock")]
    host: Binding,
}

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

impl Session for MyAgent {}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args = Args::parse();

    bind(args.host.try_into()?, MyAgent::default()).await?;

    Ok(())
}