[][src]Struct pcsc::Context

pub struct Context { /* fields omitted */ }

Library context to the PCSC service.

This structure wraps SCARDCONTEXT.

Methods

impl Context[src]

pub fn establish(scope: Scope) -> Result<Context, Error>[src]

Establish a new context.

This function wraps SCardEstablishContext (pcsclite, MSDN).

pub fn release(self) -> Result<(), (Context, Error)>[src]

Release the context.

In case of error, ownership of the context is returned to the caller.

This function wraps SCardReleaseContext (pcsclite, MSDN).

Note

Context implements Drop which automatically releases the context; you only need to call this function if you want to handle errors.

If the Context was cloned, and a clone is still alive, this function will fail with Error::CantDispose.

pub fn is_valid(&self) -> Result<(), Error>[src]

Check whether the Context is still valid.

This function wraps SCardIsValidContext (pcsclite, MSDN).

pub fn cancel(&self) -> Result<(), Error>[src]

Cancel any ongoing blocking operation in the Context.

See the cancel.rs example program.

This function wraps SCardCancel (pcsclite, MSDN).

pub fn list_readers<'buf>(
    &self,
    buffer: &'buf mut [u8]
) -> Result<ReaderNames<'buf>, Error>
[src]

List all connected card readers.

buffer is a buffer that should be large enough to hold all of the connected reader names. The function list_readers_len can be used to find the exact required length.

Returns an iterator over the reader names. The iterator yields values directly from buffer.

If the buffer is not large enough to hold all of the names, Error::InsufficientBuffer is returned.

This function wraps SCardListReaders (pcsclite, MSDN).

pub fn list_readers_len(&self) -> Result<usize, Error>[src]

Get the needed length of a buffer to be passed to list_readers.

This function wraps SCardListReaders (pcsclite, MSDN).

pub fn connect(
    &self,
    reader: &CStr,
    share_mode: ShareMode,
    preferred_protocols: Protocols
) -> Result<Card, Error>
[src]

Connect to a card which is present in a reader.

See the connect.rs example program.

This function wraps SCardConnect (pcsclite, MSDN).

pub fn get_status_change<D>(
    &self,
    timeout: D,
    readers: &mut [ReaderState]
) -> Result<(), Error> where
    D: Into<Option<Duration>>, 
[src]

Wait for card and card reader state changes.

The function blocks until the state of one of the readers changes from corresponding passed-in ReaderState. The ReaderStates are updated to report the new state.

A special reader name, \\?PnP?\Notification, can be used to detect card reader insertions and removals, as opposed to state changes of a specific reader. Use PNP_NOTIFICATION() to easily obtain a static reference to this name.

See the monitor.rs example program.

This function wraps SCardGetStatusChange (pcsclite, MSDN).

Trait Implementations

impl Clone for Context[src]

fn clone(&self) -> Self[src]

Clone the Context.

Implementation note

This is implemented in the Rust side with an Arc::clone.

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Send for Context[src]

impl Sync for Context[src]

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]