pub struct GatekeeperReader<'device> { /* private fields */ }
Expand description

High-level interface over an NFC reader. Allows reading association IDs from the realm for which it was created.

Implementations§

source§

impl<'device> GatekeeperReader<'device>

source

pub fn new(connection_string: String, realm: Realm<'device>) -> Option<Self>

Opens a connection with the NFC reader located at connection_string. Readers are tied to a particular Realm, and can only read association IDs from that particular realm.

Examples found in repository?
examples/member_project.rs (line 22)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fn main() {
  let auth_key = std::env::var("GK_REALM_MEMBER_PROJECTS_AUTH_KEY").unwrap();
  let read_key = std::env::var("GK_REALM_MEMBER_PROJECTS_READ_KEY").unwrap();
  let signing_public_key =
    std::env::var("GK_REALM_MEMBER_PROJECTS_PUBLIC_KEY").unwrap();
  let mobile_decryption_private_key =
    std::env::var("GK_REALM_MEMBER_PROJECTS_MOBILE_CRYPT_PRIVATE_KEY").unwrap();
  let mobile_private_key =
    std::env::var("GK_REALM_MEMBER_PROJECTS_MOBILE_PRIVATE_KEY").unwrap();
  let realm = Realm::new(
    RealmType::MemberProjects,
    auth_key.into_bytes(),
    read_key.into_bytes(),
    signing_public_key.as_bytes(),
    mobile_decryption_private_key.as_bytes(),
    mobile_private_key.as_bytes(),
    None,
  );
  let mut gatekeeper_reader =
    GatekeeperReader::new("pn532_uart:/dev/ttyUSB0".to_string(), realm)
      .expect("Failed to open gatekeeper");
  for tag in gatekeeper_reader.get_nearby_tags() {
    println!("Found a tag nearby: {tag}");
    if let Ok(association_id) = tag.authenticate() {
      println!("Association ID for tag: {association_id}");
    }
  }
}
source

pub fn get_nearby_tags(&mut self) -> Vec<UndifferentiatedTag<'_>>

Searches for nearby NFC tags.

Note: This doesn’t actually authenticate the NFC tags, just searches for them. You must call NfcTag::authenticate before you can know who it belongs to (or if it’s even a valid tag!)

Examples found in repository?
examples/member_project.rs (line 24)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
fn main() {
  let auth_key = std::env::var("GK_REALM_MEMBER_PROJECTS_AUTH_KEY").unwrap();
  let read_key = std::env::var("GK_REALM_MEMBER_PROJECTS_READ_KEY").unwrap();
  let signing_public_key =
    std::env::var("GK_REALM_MEMBER_PROJECTS_PUBLIC_KEY").unwrap();
  let mobile_decryption_private_key =
    std::env::var("GK_REALM_MEMBER_PROJECTS_MOBILE_CRYPT_PRIVATE_KEY").unwrap();
  let mobile_private_key =
    std::env::var("GK_REALM_MEMBER_PROJECTS_MOBILE_PRIVATE_KEY").unwrap();
  let realm = Realm::new(
    RealmType::MemberProjects,
    auth_key.into_bytes(),
    read_key.into_bytes(),
    signing_public_key.as_bytes(),
    mobile_decryption_private_key.as_bytes(),
    mobile_private_key.as_bytes(),
    None,
  );
  let mut gatekeeper_reader =
    GatekeeperReader::new("pn532_uart:/dev/ttyUSB0".to_string(), realm)
      .expect("Failed to open gatekeeper");
  for tag in gatekeeper_reader.get_nearby_tags() {
    println!("Found a tag nearby: {tag}");
    if let Ok(association_id) = tag.authenticate() {
      println!("Association ID for tag: {association_id}");
    }
  }
}

Auto Trait Implementations§

§

impl<'device> RefUnwindSafe for GatekeeperReader<'device>

§

impl<'device> !Send for GatekeeperReader<'device>

§

impl<'device> !Sync for GatekeeperReader<'device>

§

impl<'device> Unpin for GatekeeperReader<'device>

§

impl<'device> UnwindSafe for GatekeeperReader<'device>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V