File: list-readers.rs

package info (click to toggle)
rust-pcsc 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: makefile: 4
file content (20 lines) | stat: -rw-r--r-- 705 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Example of how to enumerate connected card readers.
use pcsc::*;

fn main() {
    // Get a context.
    let ctx = Context::establish(Scope::User).expect("failed to establish context");

    // First allocate the required buffer.
    let len = ctx.list_readers_len().expect("failed to list readers needed len");
    let mut readers_buf = vec![0; len];
    // Alternatively, we could have just used a sufficiently large
    // statically sized, stack allocated buffer instead, like we do in
    // other examples:
    // let mut readers_buf = [0; 2048];

    let names = ctx.list_readers(&mut readers_buf).expect("failed to list readers");
    for name in names {
        println!("{:?}", name);
    }
}