Skip to content

Commit 5853f4f

Browse files
committed
Add module level example
Signed-off-by: Wiktor Kwapisiewicz <wiktor@metacode.biz>
1 parent 22c1a09 commit 5853f4f

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

examples/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ A simple forwarding example which works as an agent and client at the same time
4343

4444
Dumps identities stored by the agent.
4545
Additionally invokes an extension and reads the result.
46+
47+
### `ssh-agent-client-blocking`
48+
49+
Dumps identities stored by the agent using blocking (synchronous) API.

src/blocking.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
//! Blocking API.
1+
//! Blocking SSH agent client API.
2+
//!
3+
//! Blocking API is always enabled since it doesn't use additional
4+
//! dependencies over what is in the `proto` module and Rust standard
5+
//! library.
6+
//!
7+
//! # Examples
8+
//!
9+
//! ```no_run
10+
//! # #[cfg(unix)]
11+
//! # fn main() -> testresult::TestResult {
12+
//! use std::os::unix::net::UnixStream;
13+
//!
14+
//! use ssh_agent_lib::blocking::Client;
15+
//!
16+
//! let mut client = Client::new(UnixStream::connect(std::env::var("SSH_AUTH_SOCK")?)?);
17+
//!
18+
//! eprintln!(
19+
//! "Identities that this agent knows of: {:#?}",
20+
//! client.request_identities()?
21+
//! );
22+
//! # Ok(()) }
23+
//! ```
224
325
use std::io::{Read, Write};
426

@@ -21,7 +43,7 @@ pub struct Client<S: Read + Write> {
2143
}
2244

2345
impl<S: Read + Write> Client<S> {
24-
/// Construct a new SSH agent client for a given transport stream.
46+
/// Construct a new SSH agent client for the given transport stream.
2547
pub fn new(stream: S) -> Self {
2648
Self { stream }
2749
}

0 commit comments

Comments
 (0)