From c56a85a45075264f1976cf8767e9adff01c26939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 26 Oct 2023 00:56:49 +0200 Subject: [PATCH] transaction: Add BinaryConversationFunc adapter --- transaction.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/transaction.go b/transaction.go index a186f2f5..6edf074e 100644 --- a/transaction.go +++ b/transaction.go @@ -197,6 +197,20 @@ func (f ConversationFunc) RespondPAM(s Style, msg string) (string, error) { return f(s, msg) } +// BinaryConversationFunc is an adapter to allow the use of ordinary functions +// as binary (only) conversation callbacks. +type BinaryConversationFunc func(BinaryPointer) ([]byte, error) + +// RespondPAMBinary is a conversation callback adapter. +func (f BinaryConversationFunc) RespondPAMBinary(ptr BinaryPointer) ([]byte, error) { + return f(ptr) +} + +// RespondPAM is a dummy conversation callback adapter. +func (f BinaryConversationFunc) RespondPAM(Style, string) (string, error) { + return "", ConvErr +} + // cbPAMConv is a wrapper for the conversation callback function. // //export cbPAMConv