Verified Commit aed1c1b8 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add poolpay.card.CardReader interface

This should hopefully do the trick
parent 0306784a
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
from __future__ import annotations

from collections.abc import Callable, Sequence
from typing import Protocol


class CardReader(Protocol):
    def read_id(self) -> Sequence[int]:
        """
        Read the UID of the MIFARE Ultralight card that is presented.

        If the presented card is not a MIFARE Ultralight card, there is more than one card presented
        at once, or there is no card presented at all, this method's behavior is undefined.
        """
        ...

    def on_card_presented(self, handle_card: Callable[[CardReader], None]) -> None:
        """
        Register the function handle_card so that it is called whenever a MIFARE Ultralight card is presented.

        If this is called multiple times, the CardReader may decide whether it only remembers and calls the
        last registered function, or all of them.
        """
        ...