rfid

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeferWrap = func(ctx context.Context, err *error) {}

DeferWrap is called by library functions when returning errors to enrich them with stack trace information. By default, this is a no-op but exists so consumers of the library can BYO their own library If context is not available in a given function context.Background() will be used

View Source
var ErrorAttrs = func(err error) slog.Attr {
	return slog.String("error", err.Error())
}

Functions

func Escapable added in v0.0.2

func Escapable[T any](ctx context.Context, fn func(context.Context) (T, error)) (_ T, err error)

Escapable runs the given func in a goroutine and waits for the response. This is useful to convert non-context aware blocking functions to be context aware with the caveat that cancellation will not abort the non-context aware function but does enabling returning early. If the context is cancelled it returns immediately with the context.Cause abandoning the goroutine If the context is already cancelled it returns immediately without invoking the func.

func LogHex

func LogHex(key string, value []byte) slog.Attr

func Must

func Must[T any](val T, err error) T

Types

type APDUer added in v0.0.2

type APDUer interface {
	APDU(context.Context, apdu.Capdu) (apdu.Rapdu, error)
}

APDUer is a higher level version of Exchanger that operates on parsed ISO7816 APDUs instead of raw byte slices

type APDUerFunc added in v0.0.2

type APDUerFunc func(context.Context, apdu.Capdu) (apdu.Rapdu, error)

APDUerFunc implements the ExchangerAPDUer interface as an APDUer.APDU func

func (APDUerFunc) APDU added in v0.0.2

func (f APDUerFunc) APDU(ctx context.Context, capdu apdu.Capdu) (apdu.Rapdu, error)

func (APDUerFunc) Exchange added in v0.0.2

func (f APDUerFunc) Exchange(ctx context.Context, capdu []byte) (_ []byte, err error)

type Exchanger added in v0.0.2

type Exchanger interface {
	Exchange(ctx context.Context, capdu []byte) ([]byte, error)
}

Exchanger is a higher level version of RawSmartCard that takes a context for cancellation

type ExchangerAPDUer added in v0.0.2

type ExchangerAPDUer interface {
	Exchanger
	APDUer
}

ExchangerAPDUer is a composite interface of Exchanger and APDUer

func RawSmartCardAPDUer added in v0.0.2

func RawSmartCardAPDUer(sc RawSmartCard) ExchangerAPDUer

RawSmartCardAPDUer transforms RawSmartCard into an ExchangerAPDUer with the ability to abandon waiting for a response if the context is cancelled

func RawSmartCardControlAPDUer added in v0.0.2

func RawSmartCardControlAPDUer(sc RawSmartCardControl, ioctl uint32) ExchangerAPDUer

RawSmartCardControlAPDUer transforms RawSmartCard into an ExchangerAPDUer by performing escape functions with the given ioctl. It also provides the ability to abandon waiting for a response if the context is cancelled

func SmartCardControlAPDUer added in v0.0.2

func SmartCardControlAPDUer(sc SmartCardControl, code uint16) ExchangerAPDUer

SmartCardControlAPDUer transforms SmartCardControl into an ExchangerAPDUer by performing control functions with the given code.

type ExchangerFunc added in v0.0.2

type ExchangerFunc func(ctx context.Context, capdu []byte) ([]byte, error)

ExchangerFunc implements the ExchangerAPDUer interface as an Exchanger.Exchange func

func (ExchangerFunc) APDU added in v0.0.2

func (f ExchangerFunc) APDU(ctx context.Context, capdu apdu.Capdu) (_ apdu.Rapdu, err error)

func (ExchangerFunc) Exchange added in v0.0.2

func (f ExchangerFunc) Exchange(ctx context.Context, capdu []byte) ([]byte, error)

type RawSmartCard added in v0.0.2

type RawSmartCard interface {
	Transmit(data []byte) ([]byte, error)
}

RawSmartCard is an interface that is implemented by *github.com/ebfe/go-scard.Card

type RawSmartCardControl added in v0.0.2

type RawSmartCardControl interface {
	Control(ioctl uint32, data []byte) ([]byte, error)
}

RawSmartCardControl is an interface that is implemented by *github.com/ebfe/go-scard.Card

type SmartCardControl added in v0.0.2

type SmartCardControl interface {
	Control(ctx context.Context, code uint16, data []byte) ([]byte, error)
}

SmartCardControl is a higher level version of RawSmartCardControl that takes control codes instead of ioctls for platform portability and accepts a context for cancellation

func RawSmartCardControlToSmartCardControl added in v0.0.2

func RawSmartCardControlToSmartCardControl(sc RawSmartCardControl, controlCodeToIoctl func(code uint16) uint32) SmartCardControl

RawSmartCardControlToSmartCardControl transforms RawSmartCardControl into an SmartCardControl with the ability to abandon waiting for a response if the context is cancelled

type SmartCardControlFunc added in v0.0.2

type SmartCardControlFunc func(ctx context.Context, code uint16, data []byte) ([]byte, error)

SmartCardControlFunc implements the SmartCardControl interface as an SmartCardControl.Control func

func (SmartCardControlFunc) Control added in v0.0.2

func (f SmartCardControlFunc) Control(ctx context.Context, code uint16, data []byte) ([]byte, error)

Directories

Path Synopsis
pm3

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL