-- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Kafka/Internal/RdKafka.chs" #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE EmptyDataDecls #-}

module Kafka.Internal.RdKafka where
import qualified Foreign.C.String as C2HSImp
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Ptr as C2HSImp
import qualified Foreign.Storable as C2HSImp
import qualified System.IO.Unsafe as C2HSImp



import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import Data.Text (Text)
import qualified Data.Text as Text
import Control.Monad (liftM)
import Data.Int (Int32, Int64)
import Data.Word (Word8)
import Foreign.Concurrent (newForeignPtr)
import qualified Foreign.Concurrent as Concurrent
import Foreign.Marshal.Alloc (alloca, allocaBytes)
import Foreign.Marshal.Array (peekArray, allocaArray, withArrayLen)
import Foreign.Storable (Storable(..))
import Foreign.Ptr (Ptr, FunPtr, castPtr, nullPtr)
import Foreign.ForeignPtr (FinalizerPtr, addForeignPtrFinalizer, newForeignPtr_, withForeignPtr)
import Foreign.C.Error (Errno(..), getErrno)
import Foreign.C.String (CString, newCString, withCAString, peekCAString, peekCString)
import Foreign.C.Types (CFile, CInt(..), CSize, CChar, CLong)
import System.IO (Handle, stdin, stdout, stderr)
import System.Posix.IO (handleToFd)
import System.Posix.Types (Fd(..))



type CInt64T = (C2HSImp.CLLong)
{-# LINE 29 "src/Kafka/Internal/RdKafka.chs" #-}

type CInt32T = (C2HSImp.CInt)
{-# LINE 30 "src/Kafka/Internal/RdKafka.chs" #-}


type CFilePtr = C2HSImp.Ptr (CFile)
{-# LINE 32 "src/Kafka/Internal/RdKafka.chs" #-}

type CSizePtr = C2HSImp.Ptr (CSize)
{-# LINE 33 "src/Kafka/Internal/RdKafka.chs" #-}


type Word8Ptr = Ptr Word8
type CCharBufPointer  = Ptr CChar

data RdKafkaTypeT = RdKafkaProducer
                  | RdKafkaConsumer
  deriving (Enum,Show,Eq)

{-# LINE 38 "src/Kafka/Internal/RdKafka.chs" #-}

data RdKafkaConfResT = RdKafkaConfUnknown
                     | RdKafkaConfInvalid
                     | RdKafkaConfOk
  deriving (Show,Eq)
instance Enum RdKafkaConfResT where
  succ RdKafkaConfUnknown = RdKafkaConfInvalid
  succ RdKafkaConfInvalid = RdKafkaConfOk
  succ RdKafkaConfOk = error "RdKafkaConfResT.succ: RdKafkaConfOk has no successor"

  pred :: RdKafkaConfResT -> RdKafkaConfResT
pred RdKafkaConfInvalid = RdKafkaConfResT
RdKafkaConfUnknown
  pred RdKafkaConfOk = RdKafkaConfResT
RdKafkaConfInvalid
  pred RdKafkaConfUnknown = error "RdKafkaConfResT.pred: RdKafkaConfUnknown has no predecessor"

  enumFromTo :: RdKafkaConfResT -> RdKafkaConfResT -> [RdKafkaConfResT]
enumFromTo from :: RdKafkaConfResT
from to :: RdKafkaConfResT
to = RdKafkaConfResT -> [RdKafkaConfResT]
forall t. Enum t => t -> [t]
go RdKafkaConfResT
from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from RdKafkaConfOk

  fromEnum RdKafkaConfUnknown = (-2)
  fromEnum RdKafkaConfInvalid = (-1)
  fromEnum RdKafkaConfOk = 0

  toEnum (-2) = RdKafkaConfUnknown
  toEnum (-1) = RdKafkaConfInvalid
  toEnum 0 = RdKafkaConfOk
  toEnum unmatched = error ("RdKafkaConfResT.toEnum: Cannot match " ++ show unmatched)

{-# LINE 39 "src/Kafka/Internal/RdKafka.chs" #-}

data RdKafkaRespErrT = RdKafkaRespErrBegin
                     | RdKafkaRespErrBadMsg
                     | RdKafkaRespErrBadCompression
                     | RdKafkaRespErrDestroy
                     | RdKafkaRespErrFail
                     | RdKafkaRespErrTransport
                     | RdKafkaRespErrCritSysResource
                     | RdKafkaRespErrResolve
                     | RdKafkaRespErrMsgTimedOut
                     | RdKafkaRespErrPartitionEof
                     | RdKafkaRespErrUnknownPartition
                     | RdKafkaRespErrFs
                     | RdKafkaRespErrUnknownTopic
                     | RdKafkaRespErrAllBrokersDown
                     | RdKafkaRespErrInvalidArg
                     | RdKafkaRespErrTimedOut
                     | RdKafkaRespErrQueueFull
                     | RdKafkaRespErrIsrInsuff
                     | RdKafkaRespErrNodeUpdate
                     | RdKafkaRespErrSsl
                     | RdKafkaRespErrWaitCoord
                     | RdKafkaRespErrUnknownGroup
                     | RdKafkaRespErrInProgress
                     | RdKafkaRespErrPrevInProgress
                     | RdKafkaRespErrExistingSubscription
                     | RdKafkaRespErrAssignPartitions
                     | RdKafkaRespErrRevokePartitions
                     | RdKafkaRespErrConflict
                     | RdKafkaRespErrState
                     | RdKafkaRespErrUnknownProtocol
                     | RdKafkaRespErrNotImplemented
                     | RdKafkaRespErrAuthentication
                     | RdKafkaRespErrNoOffset
                     | RdKafkaRespErrOutdated
                     | RdKafkaRespErrTimedOutQueue
                     | RdKafkaRespErrUnsupportedFeature
                     | RdKafkaRespErrWaitCache
                     | RdKafkaRespErrIntr
                     | RdKafkaRespErrKeySerialization
                     | RdKafkaRespErrValueSerialization
                     | RdKafkaRespErrKeyDeserialization
                     | RdKafkaRespErrValueDeserialization
                     | RdKafkaRespErrPartial
                     | RdKafkaRespErrReadOnly
                     | RdKafkaRespErrNoent
                     | RdKafkaRespErrUnderflow
                     | RdKafkaRespErrInvalidType
                     | RdKafkaRespErrRetry
                     | RdKafkaRespErrPurgeQueue
                     | RdKafkaRespErrPurgeInflight
                     | RdKafkaRespErrFatal
                     | RdKafkaRespErrInconsistent
                     | RdKafkaRespErrGaplessGuarantee
                     | RdKafkaRespErrMaxPollExceeded
                     | RdKafkaRespErrUnknownBroker
                     | RdKafkaRespErrNotConfigured
                     | RdKafkaRespErrFenced
                     | RdKafkaRespErrApplication
                     | RdKafkaRespErrAssignmentLost
                     | RdKafkaRespErrNoop
                     | RdKafkaRespErrAutoOffsetReset
                     | RdKafkaRespErrEnd
                     | RdKafkaRespErrUnknown
                     | RdKafkaRespErrNoError
                     | RdKafkaRespErrOffsetOutOfRange
                     | RdKafkaRespErrInvalidMsg
                     | RdKafkaRespErrUnknownTopicOrPart
                     | RdKafkaRespErrInvalidMsgSize
                     | RdKafkaRespErrLeaderNotAvailable
                     | RdKafkaRespErrNotLeaderForPartition
                     | RdKafkaRespErrRequestTimedOut
                     | RdKafkaRespErrBrokerNotAvailable
                     | RdKafkaRespErrReplicaNotAvailable
                     | RdKafkaRespErrMsgSizeTooLarge
                     | RdKafkaRespErrStaleCtrlEpoch
                     | RdKafkaRespErrOffsetMetadataTooLarge
                     | RdKafkaRespErrNetworkException
                     | RdKafkaRespErrCoordinatorLoadInProgress
                     | RdKafkaRespErrCoordinatorNotAvailable
                     | RdKafkaRespErrNotCoordinator
                     | RdKafkaRespErrTopicException
                     | RdKafkaRespErrRecordListTooLarge
                     | RdKafkaRespErrNotEnoughReplicas
                     | RdKafkaRespErrNotEnoughReplicasAfterAppend
                     | RdKafkaRespErrInvalidRequiredAcks
                     | RdKafkaRespErrIllegalGeneration
                     | RdKafkaRespErrInconsistentGroupProtocol
                     | RdKafkaRespErrInvalidGroupId
                     | RdKafkaRespErrUnknownMemberId
                     | RdKafkaRespErrInvalidSessionTimeout
                     | RdKafkaRespErrRebalanceInProgress
                     | RdKafkaRespErrInvalidCommitOffsetSize
                     | RdKafkaRespErrTopicAuthorizationFailed
                     | RdKafkaRespErrGroupAuthorizationFailed
                     | RdKafkaRespErrClusterAuthorizationFailed
                     | RdKafkaRespErrInvalidTimestamp
                     | RdKafkaRespErrUnsupportedSaslMechanism
                     | RdKafkaRespErrIllegalSaslState
                     | RdKafkaRespErrUnsupportedVersion
                     | RdKafkaRespErrTopicAlreadyExists
                     | RdKafkaRespErrInvalidPartitions
                     | RdKafkaRespErrInvalidReplicationFactor
                     | RdKafkaRespErrInvalidReplicaAssignment
                     | RdKafkaRespErrInvalidConfig
                     | RdKafkaRespErrNotController
                     | RdKafkaRespErrInvalidRequest
                     | RdKafkaRespErrUnsupportedForMessageFormat
                     | RdKafkaRespErrPolicyViolation
                     | RdKafkaRespErrOutOfOrderSequenceNumber
                     | RdKafkaRespErrDuplicateSequenceNumber
                     | RdKafkaRespErrInvalidProducerEpoch
                     | RdKafkaRespErrInvalidTxnState
                     | RdKafkaRespErrInvalidProducerIdMapping
                     | RdKafkaRespErrInvalidTransactionTimeout
                     | RdKafkaRespErrConcurrentTransactions
                     | RdKafkaRespErrTransactionCoordinatorFenced
                     | RdKafkaRespErrTransactionalIdAuthorizationFailed
                     | RdKafkaRespErrSecurityDisabled
                     | RdKafkaRespErrOperationNotAttempted
                     | RdKafkaRespErrKafkaStorageError
                     | RdKafkaRespErrLogDirNotFound
                     | RdKafkaRespErrSaslAuthenticationFailed
                     | RdKafkaRespErrUnknownProducerId
                     | RdKafkaRespErrReassignmentInProgress
                     | RdKafkaRespErrDelegationTokenAuthDisabled
                     | RdKafkaRespErrDelegationTokenNotFound
                     | RdKafkaRespErrDelegationTokenOwnerMismatch
                     | RdKafkaRespErrDelegationTokenRequestNotAllowed
                     | RdKafkaRespErrDelegationTokenAuthorizationFailed
                     | RdKafkaRespErrDelegationTokenExpired
                     | RdKafkaRespErrInvalidPrincipalType
                     | RdKafkaRespErrNonEmptyGroup
                     | RdKafkaRespErrGroupIdNotFound
                     | RdKafkaRespErrFetchSessionIdNotFound
                     | RdKafkaRespErrInvalidFetchSessionEpoch
                     | RdKafkaRespErrListenerNotFound
                     | RdKafkaRespErrTopicDeletionDisabled
                     | RdKafkaRespErrFencedLeaderEpoch
                     | RdKafkaRespErrUnknownLeaderEpoch
                     | RdKafkaRespErrUnsupportedCompressionType
                     | RdKafkaRespErrStaleBrokerEpoch
                     | RdKafkaRespErrOffsetNotAvailable
                     | RdKafkaRespErrMemberIdRequired
                     | RdKafkaRespErrPreferredLeaderNotAvailable
                     | RdKafkaRespErrGroupMaxSizeReached
                     | RdKafkaRespErrFencedInstanceId
                     | RdKafkaRespErrEligibleLeadersNotAvailable
                     | RdKafkaRespErrElectionNotNeeded
                     | RdKafkaRespErrNoReassignmentInProgress
                     | RdKafkaRespErrGroupSubscribedToTopic
                     | RdKafkaRespErrInvalidRecord
                     | RdKafkaRespErrUnstableOffsetCommit
                     | RdKafkaRespErrThrottlingQuotaExceeded
                     | RdKafkaRespErrProducerFenced
                     | RdKafkaRespErrResourceNotFound
                     | RdKafkaRespErrDuplicateResource
                     | RdKafkaRespErrUnacceptableCredential
                     | RdKafkaRespErrInconsistentVoterSet
                     | RdKafkaRespErrInvalidUpdateVersion
                     | RdKafkaRespErrFeatureUpdateFailed
                     | RdKafkaRespErrPrincipalDeserializationFailure
                     | RdKafkaRespErrEndAll
  deriving (Show,Eq,Bounded)
instance Enum RdKafkaRespErrT where
  succ :: RdKafkaRespErrT -> RdKafkaRespErrT
succ RdKafkaRespErrBegin = RdKafkaRespErrT
RdKafkaRespErrBadMsg
  succ RdKafkaRespErrBadMsg = RdKafkaRespErrT
RdKafkaRespErrBadCompression
  succ RdKafkaRespErrBadCompression = RdKafkaRespErrT
RdKafkaRespErrDestroy
  succ RdKafkaRespErrDestroy = RdKafkaRespErrT
RdKafkaRespErrFail
  succ RdKafkaRespErrFail = RdKafkaRespErrT
RdKafkaRespErrTransport
  succ RdKafkaRespErrTransport = RdKafkaRespErrT
RdKafkaRespErrCritSysResource
  succ RdKafkaRespErrCritSysResource = RdKafkaRespErrT
RdKafkaRespErrResolve
  succ RdKafkaRespErrResolve = RdKafkaRespErrT
RdKafkaRespErrMsgTimedOut
  succ RdKafkaRespErrMsgTimedOut = RdKafkaRespErrPartitionEof
  succ RdKafkaRespErrPartitionEof = RdKafkaRespErrUnknownPartition
  succ RdKafkaRespErrUnknownPartition = RdKafkaRespErrFs
  succ RdKafkaRespErrFs = RdKafkaRespErrUnknownTopic
  succ RdKafkaRespErrUnknownTopic = RdKafkaRespErrAllBrokersDown
  succ RdKafkaRespErrAllBrokersDown = RdKafkaRespErrInvalidArg
  succ RdKafkaRespErrInvalidArg = RdKafkaRespErrTimedOut
  succ RdKafkaRespErrTimedOut = RdKafkaRespErrQueueFull
  succ RdKafkaRespErrQueueFull = RdKafkaRespErrIsrInsuff
  succ RdKafkaRespErrIsrInsuff = RdKafkaRespErrNodeUpdate
  succ RdKafkaRespErrNodeUpdate = RdKafkaRespErrSsl
  succ RdKafkaRespErrSsl = RdKafkaRespErrWaitCoord
  succ RdKafkaRespErrWaitCoord = RdKafkaRespErrUnknownGroup
  succ RdKafkaRespErrUnknownGroup = RdKafkaRespErrT
RdKafkaRespErrInProgress
  succ RdKafkaRespErrInProgress = RdKafkaRespErrPrevInProgress
  succ RdKafkaRespErrPrevInProgress = RdKafkaRespErrT
RdKafkaRespErrExistingSubscription
  succ RdKafkaRespErrExistingSubscription = RdKafkaRespErrAssignPartitions
  succ RdKafkaRespErrAssignPartitions = RdKafkaRespErrRevokePartitions
  succ RdKafkaRespErrRevokePartitions = RdKafkaRespErrConflict
  succ RdKafkaRespErrConflict = RdKafkaRespErrState
  succ RdKafkaRespErrState = RdKafkaRespErrUnknownProtocol
  succ RdKafkaRespErrUnknownProtocol = RdKafkaRespErrNotImplemented
  succ RdKafkaRespErrNotImplemented = RdKafkaRespErrT
RdKafkaRespErrAuthentication
  succ RdKafkaRespErrAuthentication = RdKafkaRespErrNoOffset
  succ RdKafkaRespErrNoOffset = RdKafkaRespErrOutdated
  succ RdKafkaRespErrOutdated = RdKafkaRespErrTimedOutQueue
  succ RdKafkaRespErrTimedOutQueue = RdKafkaRespErrUnsupportedFeature
  succ RdKafkaRespErrUnsupportedFeature = RdKafkaRespErrWaitCache
  succ RdKafkaRespErrWaitCache = RdKafkaRespErrIntr
  succ RdKafkaRespErrIntr = RdKafkaRespErrKeySerialization
  succ RdKafkaRespErrKeySerialization = RdKafkaRespErrValueSerialization
  succ RdKafkaRespErrValueSerialization = RdKafkaRespErrKeyDeserialization
  succ RdKafkaRespErrKeyDeserialization = RdKafkaRespErrT
RdKafkaRespErrValueDeserialization
  succ RdKafkaRespErrValueDeserialization = RdKafkaRespErrPartial
  succ RdKafkaRespErrPartial = RdKafkaRespErrT
RdKafkaRespErrReadOnly
  succ RdKafkaRespErrReadOnly = RdKafkaRespErrNoent
  succ RdKafkaRespErrNoent = RdKafkaRespErrUnderflow
  succ RdKafkaRespErrUnderflow = RdKafkaRespErrInvalidType
  succ RdKafkaRespErrInvalidType = RdKafkaRespErrRetry
  succ RdKafkaRespErrRetry = RdKafkaRespErrPurgeQueue
  succ RdKafkaRespErrPurgeQueue = RdKafkaRespErrPurgeInflight
  succ RdKafkaRespErrPurgeInflight = RdKafkaRespErrFatal
  succ RdKafkaRespErrFatal = RdKafkaRespErrT
RdKafkaRespErrInconsistent
  succ RdKafkaRespErrInconsistent = RdKafkaRespErrGaplessGuarantee
  succ RdKafkaRespErrGaplessGuarantee = RdKafkaRespErrMaxPollExceeded
  succ RdKafkaRespErrMaxPollExceeded = RdKafkaRespErrUnknownBroker
  succ RdKafkaRespErrUnknownBroker = RdKafkaRespErrNotConfigured
  succ RdKafkaRespErrNotConfigured = RdKafkaRespErrFenced
  succ RdKafkaRespErrFenced = RdKafkaRespErrApplication
  succ RdKafkaRespErrApplication = RdKafkaRespErrAssignmentLost
  succ RdKafkaRespErrAssignmentLost = RdKafkaRespErrNoop
  succ RdKafkaRespErrNoop = RdKafkaRespErrAutoOffsetReset
  succ RdKafkaRespErrAutoOffsetReset = RdKafkaRespErrEnd
  succ RdKafkaRespErrEnd = RdKafkaRespErrT
RdKafkaRespErrUnknown
  succ RdKafkaRespErrUnknown = RdKafkaRespErrNoError
  succ RdKafkaRespErrNoError = RdKafkaRespErrT
RdKafkaRespErrOffsetOutOfRange
  succ RdKafkaRespErrOffsetOutOfRange = RdKafkaRespErrT
RdKafkaRespErrInvalidMsg
  succ RdKafkaRespErrInvalidMsg = RdKafkaRespErrT
RdKafkaRespErrUnknownTopicOrPart
  succ RdKafkaRespErrUnknownTopicOrPart = RdKafkaRespErrInvalidMsgSize
  succ RdKafkaRespErrInvalidMsgSize = RdKafkaRespErrLeaderNotAvailable
  succ RdKafkaRespErrLeaderNotAvailable = RdKafkaRespErrNotLeaderForPartition
  succ RdKafkaRespErrNotLeaderForPartition = RdKafkaRespErrRequestTimedOut
  succ RdKafkaRespErrRequestTimedOut = RdKafkaRespErrBrokerNotAvailable
  succ RdKafkaRespErrBrokerNotAvailable = RdKafkaRespErrReplicaNotAvailable
  succ RdKafkaRespErrReplicaNotAvailable = RdKafkaRespErrMsgSizeTooLarge
  succ RdKafkaRespErrMsgSizeTooLarge = RdKafkaRespErrT
RdKafkaRespErrStaleCtrlEpoch
  succ RdKafkaRespErrStaleCtrlEpoch = RdKafkaRespErrOffsetMetadataTooLarge
  succ RdKafkaRespErrOffsetMetadataTooLarge = RdKafkaRespErrNetworkException
  succ RdKafkaRespErrNetworkException = RdKafkaRespErrCoordinatorLoadInProgress
  succ RdKafkaRespErrCoordinatorLoadInProgress = RdKafkaRespErrCoordinatorNotAvailable
  succ RdKafkaRespErrCoordinatorNotAvailable = RdKafkaRespErrT
RdKafkaRespErrNotCoordinator
  succ RdKafkaRespErrNotCoordinator = RdKafkaRespErrT
RdKafkaRespErrTopicException
  succ RdKafkaRespErrTopicException = RdKafkaRespErrRecordListTooLarge
  succ RdKafkaRespErrRecordListTooLarge = RdKafkaRespErrNotEnoughReplicas
  succ RdKafkaRespErrNotEnoughReplicas = RdKafkaRespErrNotEnoughReplicasAfterAppend
  succ RdKafkaRespErrNotEnoughReplicasAfterAppend = RdKafkaRespErrInvalidRequiredAcks
  succ RdKafkaRespErrInvalidRequiredAcks = RdKafkaRespErrIllegalGeneration
  succ RdKafkaRespErrIllegalGeneration = RdKafkaRespErrInconsistentGroupProtocol
  succ RdKafkaRespErrInconsistentGroupProtocol = RdKafkaRespErrInvalidGroupId
  succ RdKafkaRespErrInvalidGroupId = RdKafkaRespErrT
RdKafkaRespErrUnknownMemberId
  succ RdKafkaRespErrUnknownMemberId = RdKafkaRespErrT
RdKafkaRespErrInvalidSessionTimeout
  succ RdKafkaRespErrInvalidSessionTimeout = RdKafkaRespErrRebalanceInProgress
  succ RdKafkaRespErrRebalanceInProgress = RdKafkaRespErrT
RdKafkaRespErrInvalidCommitOffsetSize
  succ RdKafkaRespErrInvalidCommitOffsetSize = RdKafkaRespErrT
RdKafkaRespErrTopicAuthorizationFailed
  succ RdKafkaRespErrTopicAuthorizationFailed = RdKafkaRespErrT
RdKafkaRespErrGroupAuthorizationFailed
  succ RdKafkaRespErrGroupAuthorizationFailed = RdKafkaRespErrT
RdKafkaRespErrClusterAuthorizationFailed
  succ RdKafkaRespErrClusterAuthorizationFailed = RdKafkaRespErrT
RdKafkaRespErrInvalidTimestamp
  succ RdKafkaRespErrInvalidTimestamp = RdKafkaRespErrUnsupportedSaslMechanism
  succ RdKafkaRespErrUnsupportedSaslMechanism = RdKafkaRespErrIllegalSaslState
  succ RdKafkaRespErrIllegalSaslState = RdKafkaRespErrUnsupportedVersion
  succ RdKafkaRespErrUnsupportedVersion = RdKafkaRespErrTopicAlreadyExists
  succ RdKafkaRespErrTopicAlreadyExists = RdKafkaRespErrInvalidPartitions
  succ RdKafkaRespErrInvalidPartitions = RdKafkaRespErrInvalidReplicationFactor
  succ RdKafkaRespErrInvalidReplicationFactor = RdKafkaRespErrInvalidReplicaAssignment
  succ RdKafkaRespErrInvalidReplicaAssignment = RdKafkaRespErrInvalidConfig
  succ RdKafkaRespErrInvalidConfig = RdKafkaRespErrNotController
  succ RdKafkaRespErrNotController = RdKafkaRespErrInvalidRequest
  succ RdKafkaRespErrInvalidRequest = RdKafkaRespErrT
RdKafkaRespErrUnsupportedForMessageFormat
  succ RdKafkaRespErrUnsupportedForMessageFormat = RdKafkaRespErrPolicyViolation
  succ RdKafkaRespErrPolicyViolation = RdKafkaRespErrOutOfOrderSequenceNumber
  succ RdKafkaRespErrOutOfOrderSequenceNumber = RdKafkaRespErrDuplicateSequenceNumber
  succ RdKafkaRespErrDuplicateSequenceNumber = RdKafkaRespErrInvalidProducerEpoch
  succ RdKafkaRespErrInvalidProducerEpoch = RdKafkaRespErrInvalidTxnState
  succ RdKafkaRespErrInvalidTxnState = RdKafkaRespErrT
RdKafkaRespErrInvalidProducerIdMapping
  succ RdKafkaRespErrInvalidProducerIdMapping = RdKafkaRespErrInvalidTransactionTimeout
  succ RdKafkaRespErrInvalidTransactionTimeout = RdKafkaRespErrConcurrentTransactions
  succ RdKafkaRespErrConcurrentTransactions = RdKafkaRespErrTransactionCoordinatorFenced
  succ RdKafkaRespErrTransactionCoordinatorFenced = RdKafkaRespErrTransactionalIdAuthorizationFailed
  succ RdKafkaRespErrTransactionalIdAuthorizationFailed = RdKafkaRespErrT
RdKafkaRespErrSecurityDisabled
  succ RdKafkaRespErrSecurityDisabled = RdKafkaRespErrT
RdKafkaRespErrOperationNotAttempted
  succ RdKafkaRespErrOperationNotAttempted = RdKafkaRespErrT
RdKafkaRespErrKafkaStorageError
  succ RdKafkaRespErrKafkaStorageError = RdKafkaRespErrLogDirNotFound
  succ RdKafkaRespErrLogDirNotFound = RdKafkaRespErrSaslAuthenticationFailed
  succ RdKafkaRespErrSaslAuthenticationFailed = RdKafkaRespErrT
RdKafkaRespErrUnknownProducerId
  succ RdKafkaRespErrUnknownProducerId = RdKafkaRespErrReassignmentInProgress
  succ RdKafkaRespErrReassignmentInProgress = RdKafkaRespErrDelegationTokenAuthDisabled
  succ RdKafkaRespErrDelegationTokenAuthDisabled = RdKafkaRespErrT
RdKafkaRespErrDelegationTokenNotFound
  succ RdKafkaRespErrDelegationTokenNotFound = RdKafkaRespErrDelegationTokenOwnerMismatch
  succ RdKafkaRespErrDelegationTokenOwnerMismatch = RdKafkaRespErrDelegationTokenRequestNotAllowed
  succ RdKafkaRespErrDelegationTokenRequestNotAllowed = RdKafkaRespErrT
RdKafkaRespErrDelegationTokenAuthorizationFailed
  succ RdKafkaRespErrDelegationTokenAuthorizationFailed = RdKafkaRespErrDelegationTokenExpired
  succ RdKafkaRespErrDelegationTokenExpired = RdKafkaRespErrInvalidPrincipalType
  succ RdKafkaRespErrInvalidPrincipalType = RdKafkaRespErrNonEmptyGroup
  succ RdKafkaRespErrNonEmptyGroup = RdKafkaRespErrGroupIdNotFound
  succ RdKafkaRespErrGroupIdNotFound = RdKafkaRespErrT
RdKafkaRespErrFetchSessionIdNotFound
  succ RdKafkaRespErrFetchSessionIdNotFound = RdKafkaRespErrT
RdKafkaRespErrInvalidFetchSessionEpoch
  succ RdKafkaRespErrInvalidFetchSessionEpoch = RdKafkaRespErrT
RdKafkaRespErrListenerNotFound
  succ RdKafkaRespErrListenerNotFound = RdKafkaRespErrTopicDeletionDisabled
  succ RdKafkaRespErrTopicDeletionDisabled = RdKafkaRespErrT
RdKafkaRespErrFencedLeaderEpoch
  succ RdKafkaRespErrFencedLeaderEpoch = RdKafkaRespErrUnknownLeaderEpoch
  succ RdKafkaRespErrUnknownLeaderEpoch = RdKafkaRespErrUnsupportedCompressionType
  succ RdKafkaRespErrUnsupportedCompressionType = RdKafkaRespErrT
RdKafkaRespErrStaleBrokerEpoch
  succ RdKafkaRespErrStaleBrokerEpoch = RdKafkaRespErrOffsetNotAvailable
  succ RdKafkaRespErrOffsetNotAvailable = RdKafkaRespErrMemberIdRequired
  succ RdKafkaRespErrMemberIdRequired = RdKafkaRespErrT
RdKafkaRespErrPreferredLeaderNotAvailable
  succ RdKafkaRespErrPreferredLeaderNotAvailable = RdKafkaRespErrGroupMaxSizeReached
  succ RdKafkaRespErrGroupMaxSizeReached = RdKafkaRespErrFencedInstanceId
  succ RdKafkaRespErrFencedInstanceId = RdKafkaRespErrEligibleLeadersNotAvailable
  succ RdKafkaRespErrEligibleLeadersNotAvailable = RdKafkaRespErrElectionNotNeeded
  succ RdKafkaRespErrElectionNotNeeded = RdKafkaRespErrT
RdKafkaRespErrNoReassignmentInProgress
  succ RdKafkaRespErrNoReassignmentInProgress = RdKafkaRespErrT
RdKafkaRespErrGroupSubscribedToTopic
  succ RdKafkaRespErrGroupSubscribedToTopic = RdKafkaRespErrT
RdKafkaRespErrInvalidRecord
  succ RdKafkaRespErrInvalidRecord = RdKafkaRespErrUnstableOffsetCommit
  succ RdKafkaRespErrUnstableOffsetCommit = RdKafkaRespErrThrottlingQuotaExceeded
  succ RdKafkaRespErrThrottlingQuotaExceeded = RdKafkaRespErrT
RdKafkaRespErrProducerFenced
  succ RdKafkaRespErrProducerFenced = RdKafkaRespErrResourceNotFound
  succ RdKafkaRespErrResourceNotFound = RdKafkaRespErrDuplicateResource
  succ RdKafkaRespErrDuplicateResource = RdKafkaRespErrT
RdKafkaRespErrUnacceptableCredential
  succ RdKafkaRespErrUnacceptableCredential = RdKafkaRespErrInconsistentVoterSet
  succ RdKafkaRespErrInconsistentVoterSet = RdKafkaRespErrInvalidUpdateVersion
  succ RdKafkaRespErrInvalidUpdateVersion = RdKafkaRespErrT
RdKafkaRespErrFeatureUpdateFailed
  succ RdKafkaRespErrFeatureUpdateFailed = RdKafkaRespErrPrincipalDeserializationFailure
  succ RdKafkaRespErrPrincipalDeserializationFailure = RdKafkaRespErrT
RdKafkaRespErrEndAll
  succ RdKafkaRespErrEndAll = String -> RdKafkaRespErrT
forall a. HasCallStack => String -> a
error "RdKafkaRespErrT.succ: RdKafkaRespErrEndAll has no successor"

  pred :: RdKafkaRespErrT -> RdKafkaRespErrT
pred RdKafkaRespErrBadMsg = RdKafkaRespErrT
RdKafkaRespErrBegin
  pred RdKafkaRespErrBadCompression = RdKafkaRespErrT
RdKafkaRespErrBadMsg
  pred RdKafkaRespErrDestroy = RdKafkaRespErrT
RdKafkaRespErrBadCompression
  pred RdKafkaRespErrFail = RdKafkaRespErrT
RdKafkaRespErrDestroy
  pred RdKafkaRespErrTransport = RdKafkaRespErrFail
  pred RdKafkaRespErrCritSysResource = RdKafkaRespErrTransport
  pred RdKafkaRespErrResolve = RdKafkaRespErrT
RdKafkaRespErrCritSysResource
  pred RdKafkaRespErrMsgTimedOut = RdKafkaRespErrResolve
  pred RdKafkaRespErrPartitionEof = RdKafkaRespErrMsgTimedOut
  pred RdKafkaRespErrUnknownPartition = RdKafkaRespErrT
RdKafkaRespErrPartitionEof
  pred RdKafkaRespErrFs = RdKafkaRespErrUnknownPartition
  pred RdKafkaRespErrUnknownTopic = RdKafkaRespErrFs
  pred RdKafkaRespErrAllBrokersDown = RdKafkaRespErrT
RdKafkaRespErrUnknownTopic
  pred RdKafkaRespErrInvalidArg = RdKafkaRespErrAllBrokersDown
  pred RdKafkaRespErrTimedOut = RdKafkaRespErrInvalidArg
  pred RdKafkaRespErrQueueFull = RdKafkaRespErrTimedOut
  pred RdKafkaRespErrIsrInsuff = RdKafkaRespErrQueueFull
  pred RdKafkaRespErrNodeUpdate = RdKafkaRespErrT
RdKafkaRespErrIsrInsuff
  pred RdKafkaRespErrSsl = RdKafkaRespErrT
RdKafkaRespErrNodeUpdate
  pred RdKafkaRespErrWaitCoord = RdKafkaRespErrSsl
  pred RdKafkaRespErrUnknownGroup = RdKafkaRespErrT
RdKafkaRespErrWaitCoord
  pred RdKafkaRespErrInProgress = RdKafkaRespErrUnknownGroup
  pred RdKafkaRespErrPrevInProgress = RdKafkaRespErrInProgress
  pred RdKafkaRespErrExistingSubscription = RdKafkaRespErrT
RdKafkaRespErrPrevInProgress
  pred RdKafkaRespErrAssignPartitions = RdKafkaRespErrExistingSubscription
  pred RdKafkaRespErrRevokePartitions = RdKafkaRespErrAssignPartitions
  pred RdKafkaRespErrConflict = RdKafkaRespErrT
RdKafkaRespErrRevokePartitions
  pred RdKafkaRespErrState = RdKafkaRespErrConflict
  pred RdKafkaRespErrUnknownProtocol = RdKafkaRespErrState
  pred RdKafkaRespErrNotImplemented = RdKafkaRespErrUnknownProtocol
  pred RdKafkaRespErrAuthentication = RdKafkaRespErrNotImplemented
  pred RdKafkaRespErrNoOffset = RdKafkaRespErrT
RdKafkaRespErrAuthentication
  pred RdKafkaRespErrOutdated = RdKafkaRespErrT
RdKafkaRespErrNoOffset
  pred RdKafkaRespErrTimedOutQueue = RdKafkaRespErrT
RdKafkaRespErrOutdated
  pred RdKafkaRespErrUnsupportedFeature = RdKafkaRespErrTimedOutQueue
  pred RdKafkaRespErrWaitCache = RdKafkaRespErrUnsupportedFeature
  pred RdKafkaRespErrIntr = RdKafkaRespErrT
RdKafkaRespErrWaitCache
  pred RdKafkaRespErrKeySerialization = RdKafkaRespErrIntr
  pred RdKafkaRespErrValueSerialization = RdKafkaRespErrKeySerialization
  pred RdKafkaRespErrKeyDeserialization = RdKafkaRespErrT
RdKafkaRespErrValueSerialization
  pred RdKafkaRespErrValueDeserialization = RdKafkaRespErrKeyDeserialization
  pred RdKafkaRespErrPartial = RdKafkaRespErrValueDeserialization
  pred RdKafkaRespErrReadOnly = RdKafkaRespErrT
RdKafkaRespErrPartial
  pred RdKafkaRespErrNoent = RdKafkaRespErrReadOnly
  pred RdKafkaRespErrUnderflow = RdKafkaRespErrNoent
  pred RdKafkaRespErrInvalidType = RdKafkaRespErrUnderflow
  pred RdKafkaRespErrRetry = RdKafkaRespErrInvalidType
  pred RdKafkaRespErrPurgeQueue = RdKafkaRespErrRetry
  pred RdKafkaRespErrPurgeInflight = RdKafkaRespErrPurgeQueue
  pred RdKafkaRespErrFatal = RdKafkaRespErrPurgeInflight
  pred RdKafkaRespErrInconsistent = RdKafkaRespErrT
RdKafkaRespErrFatal
  pred RdKafkaRespErrGaplessGuarantee = RdKafkaRespErrT
RdKafkaRespErrInconsistent
  pred RdKafkaRespErrMaxPollExceeded = RdKafkaRespErrGaplessGuarantee
  pred RdKafkaRespErrUnknownBroker = RdKafkaRespErrMaxPollExceeded
  pred RdKafkaRespErrNotConfigured = RdKafkaRespErrT
RdKafkaRespErrUnknownBroker
  pred RdKafkaRespErrFenced = RdKafkaRespErrNotConfigured
  pred RdKafkaRespErrApplication = RdKafkaRespErrFenced
  pred RdKafkaRespErrAssignmentLost = RdKafkaRespErrT
RdKafkaRespErrApplication
  pred RdKafkaRespErrNoop = RdKafkaRespErrAssignmentLost
  pred RdKafkaRespErrAutoOffsetReset = RdKafkaRespErrNoop
  pred RdKafkaRespErrEnd = RdKafkaRespErrT
RdKafkaRespErrAutoOffsetReset
  pred RdKafkaRespErrUnknown = RdKafkaRespErrEnd
  pred RdKafkaRespErrNoError = RdKafkaRespErrUnknown
  pred RdKafkaRespErrOffsetOutOfRange = RdKafkaRespErrNoError
  pred RdKafkaRespErrInvalidMsg = RdKafkaRespErrOffsetOutOfRange
  pred RdKafkaRespErrUnknownTopicOrPart = RdKafkaRespErrT
RdKafkaRespErrInvalidMsg
  pred RdKafkaRespErrInvalidMsgSize = RdKafkaRespErrT
RdKafkaRespErrUnknownTopicOrPart
  pred RdKafkaRespErrLeaderNotAvailable = RdKafkaRespErrT
RdKafkaRespErrInvalidMsgSize
  pred RdKafkaRespErrNotLeaderForPartition = RdKafkaRespErrLeaderNotAvailable
  pred RdKafkaRespErrRequestTimedOut = RdKafkaRespErrT
RdKafkaRespErrNotLeaderForPartition
  pred RdKafkaRespErrBrokerNotAvailable = RdKafkaRespErrRequestTimedOut
  pred RdKafkaRespErrReplicaNotAvailable = RdKafkaRespErrBrokerNotAvailable
  pred RdKafkaRespErrMsgSizeTooLarge = RdKafkaRespErrT
RdKafkaRespErrReplicaNotAvailable
  pred RdKafkaRespErrStaleCtrlEpoch = RdKafkaRespErrMsgSizeTooLarge
  pred RdKafkaRespErrOffsetMetadataTooLarge = RdKafkaRespErrStaleCtrlEpoch
  pred RdKafkaRespErrNetworkException = RdKafkaRespErrT
RdKafkaRespErrOffsetMetadataTooLarge
  pred RdKafkaRespErrCoordinatorLoadInProgress = RdKafkaRespErrNetworkException
  pred RdKafkaRespErrCoordinatorNotAvailable = RdKafkaRespErrCoordinatorLoadInProgress
  pred RdKafkaRespErrNotCoordinator = RdKafkaRespErrCoordinatorNotAvailable
  pred RdKafkaRespErrTopicException = RdKafkaRespErrNotCoordinator
  pred RdKafkaRespErrRecordListTooLarge = RdKafkaRespErrT
RdKafkaRespErrTopicException
  pred RdKafkaRespErrNotEnoughReplicas = RdKafkaRespErrT
RdKafkaRespErrRecordListTooLarge
  pred RdKafkaRespErrNotEnoughReplicasAfterAppend = RdKafkaRespErrNotEnoughReplicas
  pred RdKafkaRespErrInvalidRequiredAcks = RdKafkaRespErrNotEnoughReplicasAfterAppend
  pred RdKafkaRespErrIllegalGeneration = RdKafkaRespErrInvalidRequiredAcks
  pred RdKafkaRespErrInconsistentGroupProtocol = RdKafkaRespErrIllegalGeneration
  pred RdKafkaRespErrInvalidGroupId = RdKafkaRespErrInconsistentGroupProtocol
  pred RdKafkaRespErrUnknownMemberId = RdKafkaRespErrT
RdKafkaRespErrInvalidGroupId
  pred RdKafkaRespErrInvalidSessionTimeout = RdKafkaRespErrUnknownMemberId
  pred RdKafkaRespErrRebalanceInProgress = RdKafkaRespErrInvalidSessionTimeout
  pred RdKafkaRespErrInvalidCommitOffsetSize = RdKafkaRespErrRebalanceInProgress
  pred RdKafkaRespErrTopicAuthorizationFailed = RdKafkaRespErrInvalidCommitOffsetSize
  pred RdKafkaRespErrGroupAuthorizationFailed = RdKafkaRespErrTopicAuthorizationFailed
  pred RdKafkaRespErrClusterAuthorizationFailed = RdKafkaRespErrGroupAuthorizationFailed
  pred RdKafkaRespErrInvalidTimestamp = RdKafkaRespErrClusterAuthorizationFailed
  pred RdKafkaRespErrUnsupportedSaslMechanism = RdKafkaRespErrInvalidTimestamp
  pred RdKafkaRespErrIllegalSaslState = RdKafkaRespErrUnsupportedSaslMechanism
  pred RdKafkaRespErrUnsupportedVersion = RdKafkaRespErrIllegalSaslState
  pred RdKafkaRespErrTopicAlreadyExists = RdKafkaRespErrUnsupportedVersion
  pred RdKafkaRespErrInvalidPartitions = RdKafkaRespErrTopicAlreadyExists
  pred RdKafkaRespErrInvalidReplicationFactor = RdKafkaRespErrT
RdKafkaRespErrInvalidPartitions
  pred RdKafkaRespErrInvalidReplicaAssignment = RdKafkaRespErrInvalidReplicationFactor
  pred RdKafkaRespErrInvalidConfig = RdKafkaRespErrInvalidReplicaAssignment
  pred RdKafkaRespErrNotController = RdKafkaRespErrT
RdKafkaRespErrInvalidConfig
  pred RdKafkaRespErrInvalidRequest = RdKafkaRespErrNotController
  pred RdKafkaRespErrUnsupportedForMessageFormat = RdKafkaRespErrInvalidRequest
  pred RdKafkaRespErrPolicyViolation = RdKafkaRespErrT
RdKafkaRespErrUnsupportedForMessageFormat
  pred RdKafkaRespErrOutOfOrderSequenceNumber = RdKafkaRespErrPolicyViolation
  pred RdKafkaRespErrDuplicateSequenceNumber = RdKafkaRespErrOutOfOrderSequenceNumber
  pred RdKafkaRespErrInvalidProducerEpoch = RdKafkaRespErrDuplicateSequenceNumber
  pred RdKafkaRespErrInvalidTxnState = RdKafkaRespErrInvalidProducerEpoch
  pred RdKafkaRespErrInvalidProducerIdMapping = RdKafkaRespErrT
RdKafkaRespErrInvalidTxnState
  pred RdKafkaRespErrInvalidTransactionTimeout = RdKafkaRespErrT
RdKafkaRespErrInvalidProducerIdMapping
  pred RdKafkaRespErrConcurrentTransactions = RdKafkaRespErrT
RdKafkaRespErrInvalidTransactionTimeout
  pred RdKafkaRespErrTransactionCoordinatorFenced = RdKafkaRespErrT
RdKafkaRespErrConcurrentTransactions
  pred RdKafkaRespErrTransactionalIdAuthorizationFailed = RdKafkaRespErrTransactionCoordinatorFenced
  pred RdKafkaRespErrSecurityDisabled = RdKafkaRespErrTransactionalIdAuthorizationFailed
  pred RdKafkaRespErrOperationNotAttempted = RdKafkaRespErrSecurityDisabled
  pred RdKafkaRespErrKafkaStorageError = RdKafkaRespErrOperationNotAttempted
  pred RdKafkaRespErrLogDirNotFound = RdKafkaRespErrKafkaStorageError
  pred RdKafkaRespErrSaslAuthenticationFailed = RdKafkaRespErrLogDirNotFound
  pred RdKafkaRespErrUnknownProducerId = RdKafkaRespErrT
RdKafkaRespErrSaslAuthenticationFailed
  pred RdKafkaRespErrReassignmentInProgress = RdKafkaRespErrT
RdKafkaRespErrUnknownProducerId
  pred RdKafkaRespErrDelegationTokenAuthDisabled = RdKafkaRespErrT
RdKafkaRespErrReassignmentInProgress
  pred RdKafkaRespErrDelegationTokenNotFound = RdKafkaRespErrT
RdKafkaRespErrDelegationTokenAuthDisabled
  pred RdKafkaRespErrDelegationTokenOwnerMismatch = RdKafkaRespErrT
RdKafkaRespErrDelegationTokenNotFound
  pred RdKafkaRespErrDelegationTokenRequestNotAllowed = RdKafkaRespErrT
RdKafkaRespErrDelegationTokenOwnerMismatch
  pred RdKafkaRespErrDelegationTokenAuthorizationFailed = RdKafkaRespErrDelegationTokenRequestNotAllowed
  pred RdKafkaRespErrDelegationTokenExpired = RdKafkaRespErrDelegationTokenAuthorizationFailed
  pred RdKafkaRespErrInvalidPrincipalType = RdKafkaRespErrDelegationTokenExpired
  pred RdKafkaRespErrNonEmptyGroup = RdKafkaRespErrInvalidPrincipalType
  pred RdKafkaRespErrGroupIdNotFound = RdKafkaRespErrNonEmptyGroup
  pred RdKafkaRespErrFetchSessionIdNotFound = RdKafkaRespErrGroupIdNotFound
  pred RdKafkaRespErrInvalidFetchSessionEpoch = RdKafkaRespErrFetchSessionIdNotFound
  pred RdKafkaRespErrListenerNotFound = RdKafkaRespErrInvalidFetchSessionEpoch
  pred RdKafkaRespErrTopicDeletionDisabled = RdKafkaRespErrListenerNotFound
  pred RdKafkaRespErrFencedLeaderEpoch = RdKafkaRespErrTopicDeletionDisabled
  pred RdKafkaRespErrUnknownLeaderEpoch = RdKafkaRespErrT
RdKafkaRespErrFencedLeaderEpoch
  pred RdKafkaRespErrUnsupportedCompressionType = RdKafkaRespErrT
RdKafkaRespErrUnknownLeaderEpoch
  pred RdKafkaRespErrStaleBrokerEpoch = RdKafkaRespErrT
RdKafkaRespErrUnsupportedCompressionType
  pred RdKafkaRespErrOffsetNotAvailable = RdKafkaRespErrT
RdKafkaRespErrStaleBrokerEpoch
  pred RdKafkaRespErrMemberIdRequired = RdKafkaRespErrT
RdKafkaRespErrOffsetNotAvailable
  pred RdKafkaRespErrPreferredLeaderNotAvailable = RdKafkaRespErrT
RdKafkaRespErrMemberIdRequired
  pred RdKafkaRespErrGroupMaxSizeReached = RdKafkaRespErrT
RdKafkaRespErrPreferredLeaderNotAvailable
  pred RdKafkaRespErrFencedInstanceId = RdKafkaRespErrT
RdKafkaRespErrGroupMaxSizeReached
  pred RdKafkaRespErrEligibleLeadersNotAvailable = RdKafkaRespErrT
RdKafkaRespErrFencedInstanceId
  pred RdKafkaRespErrElectionNotNeeded = RdKafkaRespErrT
RdKafkaRespErrEligibleLeadersNotAvailable
  pred RdKafkaRespErrNoReassignmentInProgress = RdKafkaRespErrElectionNotNeeded
  pred RdKafkaRespErrGroupSubscribedToTopic = RdKafkaRespErrNoReassignmentInProgress
  pred RdKafkaRespErrInvalidRecord = RdKafkaRespErrGroupSubscribedToTopic
  pred RdKafkaRespErrUnstableOffsetCommit = RdKafkaRespErrInvalidRecord
  pred RdKafkaRespErrThrottlingQuotaExceeded = RdKafkaRespErrUnstableOffsetCommit
  pred RdKafkaRespErrProducerFenced = RdKafkaRespErrThrottlingQuotaExceeded
  pred RdKafkaRespErrResourceNotFound = RdKafkaRespErrProducerFenced
  pred RdKafkaRespErrDuplicateResource = RdKafkaRespErrResourceNotFound
  pred RdKafkaRespErrUnacceptableCredential = RdKafkaRespErrDuplicateResource
  pred RdKafkaRespErrInconsistentVoterSet = RdKafkaRespErrUnacceptableCredential
  pred RdKafkaRespErrInvalidUpdateVersion = RdKafkaRespErrT
RdKafkaRespErrInconsistentVoterSet
  pred RdKafkaRespErrFeatureUpdateFailed = RdKafkaRespErrInvalidUpdateVersion
  pred RdKafkaRespErrPrincipalDeserializationFailure = RdKafkaRespErrFeatureUpdateFailed
  pred RdKafkaRespErrEndAll = RdKafkaRespErrT
RdKafkaRespErrPrincipalDeserializationFailure
  pred RdKafkaRespErrBegin = error "RdKafkaRespErrT.pred: RdKafkaRespErrBegin has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom :: RdKafkaRespErrT -> [RdKafkaRespErrT]
enumFrom from :: RdKafkaRespErrT
from = RdKafkaRespErrT -> RdKafkaRespErrT -> [RdKafkaRespErrT]
forall a. Enum a => a -> a -> [a]
enumFromTo RdKafkaRespErrT
from RdKafkaRespErrT
RdKafkaRespErrEndAll

  fromEnum :: RdKafkaRespErrT -> Int
fromEnum RdKafkaRespErrBegin = (-200)
  fromEnum RdKafkaRespErrBadMsg = (-199)
  fromEnum RdKafkaRespErrBadCompression = (-198)
  fromEnum RdKafkaRespErrDestroy = (-197)
  fromEnum RdKafkaRespErrFail = (-196)
  fromEnum RdKafkaRespErrTransport = (-195)
  fromEnum RdKafkaRespErrCritSysResource = (-194)
  fromEnum RdKafkaRespErrResolve = (-193)
  fromEnum RdKafkaRespErrMsgTimedOut = (-192)
  fromEnum RdKafkaRespErrPartitionEof = (-191)
  fromEnum RdKafkaRespErrUnknownPartition = (-190)
  fromEnum RdKafkaRespErrFs = (-189)
  fromEnum RdKafkaRespErrUnknownTopic = (-188)
  fromEnum RdKafkaRespErrAllBrokersDown = (-187)
  fromEnum RdKafkaRespErrInvalidArg = (-186)
  fromEnum RdKafkaRespErrTimedOut = (-185)
  fromEnum RdKafkaRespErrQueueFull = (-184)
  fromEnum RdKafkaRespErrIsrInsuff = (-183)
  fromEnum RdKafkaRespErrNodeUpdate = (-182)
  fromEnum RdKafkaRespErrSsl = (-181)
  fromEnum RdKafkaRespErrWaitCoord = (-180)
  fromEnum RdKafkaRespErrUnknownGroup = (-179)
  fromEnum RdKafkaRespErrInProgress = (-178)
  fromEnum RdKafkaRespErrPrevInProgress = (-177)
  fromEnum RdKafkaRespErrExistingSubscription = (-176)
  fromEnum RdKafkaRespErrAssignPartitions = (-175)
  fromEnum RdKafkaRespErrRevokePartitions = (-174)
  fromEnum RdKafkaRespErrConflict = (-173)
  fromEnum RdKafkaRespErrState = (-172)
  fromEnum RdKafkaRespErrUnknownProtocol = (-171)
  fromEnum RdKafkaRespErrNotImplemented = (-170)
  fromEnum RdKafkaRespErrAuthentication = (-169)
  fromEnum RdKafkaRespErrNoOffset = (-168)
  fromEnum RdKafkaRespErrOutdated = (-167)
  fromEnum RdKafkaRespErrTimedOutQueue = (-166)
  fromEnum RdKafkaRespErrUnsupportedFeature = (-165)
  fromEnum RdKafkaRespErrWaitCache = (-164)
  fromEnum RdKafkaRespErrIntr = (-163)
  fromEnum RdKafkaRespErrKeySerialization = (-162)
  fromEnum RdKafkaRespErrValueSerialization = (-161)
  fromEnum RdKafkaRespErrKeyDeserialization = (-160)
  fromEnum RdKafkaRespErrValueDeserialization = (-159)
  fromEnum RdKafkaRespErrPartial = (-158)
  fromEnum RdKafkaRespErrReadOnly = (-157)
  fromEnum RdKafkaRespErrNoent = (-156)
  fromEnum RdKafkaRespErrUnderflow = (-155)
  fromEnum RdKafkaRespErrInvalidType = (-154)
  fromEnum RdKafkaRespErrRetry = (-153)
  fromEnum RdKafkaRespErrPurgeQueue = (-152)
  fromEnum RdKafkaRespErrPurgeInflight = (-151)
  fromEnum RdKafkaRespErrFatal = (-150)
  fromEnum RdKafkaRespErrInconsistent = (-149)
  fromEnum RdKafkaRespErrGaplessGuarantee = (-148)
  fromEnum RdKafkaRespErrMaxPollExceeded = (-147)
  fromEnum RdKafkaRespErrUnknownBroker = (-146)
  fromEnum RdKafkaRespErrNotConfigured = (-145)
  fromEnum RdKafkaRespErrFenced = (-144)
  fromEnum RdKafkaRespErrApplication = (-143)
  fromEnum RdKafkaRespErrAssignmentLost = (-142)
  fromEnum RdKafkaRespErrNoop = (-141)
  fromEnum RdKafkaRespErrAutoOffsetReset = (-140)
  fromEnum RdKafkaRespErrEnd = (-100)
  fromEnum RdKafkaRespErrUnknown = (-1)
  fromEnum RdKafkaRespErrNoError = 0
  fromEnum RdKafkaRespErrOffsetOutOfRange = 1
  fromEnum RdKafkaRespErrInvalidMsg = 2
  fromEnum RdKafkaRespErrUnknownTopicOrPart = 3
  fromEnum RdKafkaRespErrInvalidMsgSize = 4
  fromEnum RdKafkaRespErrLeaderNotAvailable = 5
  fromEnum RdKafkaRespErrNotLeaderForPartition = 6
  fromEnum RdKafkaRespErrRequestTimedOut = 7
  fromEnum RdKafkaRespErrBrokerNotAvailable = 8
  fromEnum RdKafkaRespErrReplicaNotAvailable = 9
  fromEnum RdKafkaRespErrMsgSizeTooLarge = 10
  fromEnum RdKafkaRespErrStaleCtrlEpoch = 11
  fromEnum RdKafkaRespErrOffsetMetadataTooLarge = 12
  fromEnum RdKafkaRespErrNetworkException = 13
  fromEnum RdKafkaRespErrCoordinatorLoadInProgress = 14
  fromEnum RdKafkaRespErrCoordinatorNotAvailable = 15
  fromEnum RdKafkaRespErrNotCoordinator = 16
  fromEnum RdKafkaRespErrTopicException = 17
  fromEnum RdKafkaRespErrRecordListTooLarge = 18
  fromEnum RdKafkaRespErrNotEnoughReplicas = 19
  fromEnum RdKafkaRespErrNotEnoughReplicasAfterAppend = 20
  fromEnum RdKafkaRespErrInvalidRequiredAcks = 21
  fromEnum RdKafkaRespErrIllegalGeneration = 22
  fromEnum RdKafkaRespErrInconsistentGroupProtocol = 23
  fromEnum RdKafkaRespErrInvalidGroupId = 24
  fromEnum RdKafkaRespErrUnknownMemberId = 25
  fromEnum RdKafkaRespErrInvalidSessionTimeout = 26
  fromEnum RdKafkaRespErrRebalanceInProgress = 27
  fromEnum RdKafkaRespErrInvalidCommitOffsetSize = 28
  fromEnum RdKafkaRespErrTopicAuthorizationFailed = 29
  fromEnum RdKafkaRespErrGroupAuthorizationFailed = 30
  fromEnum RdKafkaRespErrClusterAuthorizationFailed = 31
  fromEnum RdKafkaRespErrInvalidTimestamp = 32
  fromEnum RdKafkaRespErrUnsupportedSaslMechanism = 33
  fromEnum RdKafkaRespErrIllegalSaslState = 34
  fromEnum RdKafkaRespErrUnsupportedVersion = 35
  fromEnum RdKafkaRespErrTopicAlreadyExists = 36
  fromEnum RdKafkaRespErrInvalidPartitions = 37
  fromEnum RdKafkaRespErrInvalidReplicationFactor = 38
  fromEnum RdKafkaRespErrInvalidReplicaAssignment = 39
  fromEnum RdKafkaRespErrInvalidConfig = 40
  fromEnum RdKafkaRespErrNotController = 41
  fromEnum RdKafkaRespErrInvalidRequest = 42
  fromEnum RdKafkaRespErrUnsupportedForMessageFormat = 43
  fromEnum RdKafkaRespErrPolicyViolation = 44
  fromEnum RdKafkaRespErrOutOfOrderSequenceNumber = 45
  fromEnum RdKafkaRespErrDuplicateSequenceNumber = 46
  fromEnum RdKafkaRespErrInvalidProducerEpoch = 47
  fromEnum RdKafkaRespErrInvalidTxnState = 48
  fromEnum RdKafkaRespErrInvalidProducerIdMapping = 49
  fromEnum RdKafkaRespErrInvalidTransactionTimeout = 50
  fromEnum RdKafkaRespErrConcurrentTransactions = 51
  fromEnum RdKafkaRespErrTransactionCoordinatorFenced = 52
  fromEnum RdKafkaRespErrTransactionalIdAuthorizationFailed = 53
  fromEnum RdKafkaRespErrSecurityDisabled = 54
  fromEnum RdKafkaRespErrOperationNotAttempted = 55
  fromEnum RdKafkaRespErrKafkaStorageError = 56
  fromEnum RdKafkaRespErrLogDirNotFound = 57
  fromEnum RdKafkaRespErrSaslAuthenticationFailed = 58
  fromEnum RdKafkaRespErrUnknownProducerId = 59
  fromEnum RdKafkaRespErrReassignmentInProgress = 60
  fromEnum RdKafkaRespErrDelegationTokenAuthDisabled = 61
  fromEnum RdKafkaRespErrDelegationTokenNotFound = 62
  fromEnum RdKafkaRespErrDelegationTokenOwnerMismatch = 63
  fromEnum RdKafkaRespErrDelegationTokenRequestNotAllowed = 64
  fromEnum RdKafkaRespErrDelegationTokenAuthorizationFailed = 65
  fromEnum RdKafkaRespErrDelegationTokenExpired = 66
  fromEnum RdKafkaRespErrInvalidPrincipalType = 67
  fromEnum RdKafkaRespErrNonEmptyGroup = 68
  fromEnum RdKafkaRespErrGroupIdNotFound = 69
  fromEnum RdKafkaRespErrFetchSessionIdNotFound = 70
  fromEnum RdKafkaRespErrInvalidFetchSessionEpoch = 71
  fromEnum RdKafkaRespErrListenerNotFound = 72
  fromEnum RdKafkaRespErrTopicDeletionDisabled = 73
  fromEnum RdKafkaRespErrFencedLeaderEpoch = 74
  fromEnum RdKafkaRespErrUnknownLeaderEpoch = 75
  fromEnum RdKafkaRespErrUnsupportedCompressionType = 76
  fromEnum RdKafkaRespErrStaleBrokerEpoch = 77
  fromEnum RdKafkaRespErrOffsetNotAvailable = 78
  fromEnum RdKafkaRespErrMemberIdRequired = 79
  fromEnum RdKafkaRespErrPreferredLeaderNotAvailable = 80
  fromEnum RdKafkaRespErrGroupMaxSizeReached = 81
  fromEnum RdKafkaRespErrFencedInstanceId = 82
  fromEnum RdKafkaRespErrEligibleLeadersNotAvailable = 83
  fromEnum RdKafkaRespErrElectionNotNeeded = 84
  fromEnum RdKafkaRespErrNoReassignmentInProgress = 85
  fromEnum RdKafkaRespErrGroupSubscribedToTopic = 86
  fromEnum RdKafkaRespErrInvalidRecord = 87
  fromEnum RdKafkaRespErrUnstableOffsetCommit = 88
  fromEnum RdKafkaRespErrThrottlingQuotaExceeded = 89
  fromEnum RdKafkaRespErrProducerFenced = 90
  fromEnum RdKafkaRespErrResourceNotFound = 91
  fromEnum RdKafkaRespErrDuplicateResource = 92
  fromEnum RdKafkaRespErrUnacceptableCredential = 93
  fromEnum RdKafkaRespErrInconsistentVoterSet = 94
  fromEnum RdKafkaRespErrInvalidUpdateVersion = 95
  fromEnum RdKafkaRespErrFeatureUpdateFailed = 96
  fromEnum RdKafkaRespErrPrincipalDeserializationFailure = 97
  fromEnum RdKafkaRespErrEndAll = 98

  toEnum (-200) = RdKafkaRespErrBegin
  toEnum (-199) = RdKafkaRespErrBadMsg
  toEnum (-198) = RdKafkaRespErrBadCompression
  toEnum (-197) = RdKafkaRespErrDestroy
  toEnum (-196) = RdKafkaRespErrFail
  toEnum (-195) = RdKafkaRespErrTransport
  toEnum (-194) = RdKafkaRespErrCritSysResource
  toEnum (-193) = RdKafkaRespErrResolve
  toEnum (-192) = RdKafkaRespErrMsgTimedOut
  toEnum (-191) = RdKafkaRespErrPartitionEof
  toEnum (-190) = RdKafkaRespErrUnknownPartition
  toEnum (-189) = RdKafkaRespErrFs
  toEnum (-188) = RdKafkaRespErrUnknownTopic
  toEnum (-187) = RdKafkaRespErrAllBrokersDown
  toEnum (-186) = RdKafkaRespErrInvalidArg
  toEnum (-185) = RdKafkaRespErrTimedOut
  toEnum (-184) = RdKafkaRespErrQueueFull
  toEnum (-183) = RdKafkaRespErrIsrInsuff
  toEnum (-182) = RdKafkaRespErrNodeUpdate
  toEnum (-181) = RdKafkaRespErrSsl
  toEnum (-180) = RdKafkaRespErrWaitCoord
  toEnum (-179) = RdKafkaRespErrUnknownGroup
  toEnum (-178) = RdKafkaRespErrInProgress
  toEnum (-177) = RdKafkaRespErrPrevInProgress
  toEnum (-176) = RdKafkaRespErrExistingSubscription
  toEnum (-175) = RdKafkaRespErrAssignPartitions
  toEnum (-174) = RdKafkaRespErrRevokePartitions
  toEnum (-173) = RdKafkaRespErrConflict
  toEnum (-172) = RdKafkaRespErrState
  toEnum (-171) = RdKafkaRespErrUnknownProtocol
  toEnum (-170) = RdKafkaRespErrNotImplemented
  toEnum (-169) = RdKafkaRespErrAuthentication
  toEnum (-168) = RdKafkaRespErrNoOffset
  toEnum (-167) = RdKafkaRespErrOutdated
  toEnum (-166) = RdKafkaRespErrTimedOutQueue
  toEnum (-165) = RdKafkaRespErrUnsupportedFeature
  toEnum (-164) = RdKafkaRespErrWaitCache
  toEnum (-163) = RdKafkaRespErrIntr
  toEnum (-162) = RdKafkaRespErrKeySerialization
  toEnum (-161) = RdKafkaRespErrValueSerialization
  toEnum (-160) = RdKafkaRespErrKeyDeserialization
  toEnum (-159) = RdKafkaRespErrValueDeserialization
  toEnum (-158) = RdKafkaRespErrPartial
  toEnum (-157) = RdKafkaRespErrReadOnly
  toEnum (-156) = RdKafkaRespErrNoent
  toEnum (-155) = RdKafkaRespErrUnderflow
  toEnum (-154) = RdKafkaRespErrInvalidType
  toEnum (-153) = RdKafkaRespErrRetry
  toEnum (-152) = RdKafkaRespErrPurgeQueue
  toEnum (-151) = RdKafkaRespErrPurgeInflight
  toEnum (-150) = RdKafkaRespErrFatal
  toEnum (-149) = RdKafkaRespErrInconsistent
  toEnum (-148) = RdKafkaRespErrGaplessGuarantee
  toEnum (-147) = RdKafkaRespErrMaxPollExceeded
  toEnum (-146) = RdKafkaRespErrUnknownBroker
  toEnum (-145) = RdKafkaRespErrNotConfigured
  toEnum (-144) = RdKafkaRespErrFenced
  toEnum (-143) = RdKafkaRespErrApplication
  toEnum (-142) = RdKafkaRespErrAssignmentLost
  toEnum (-141) = RdKafkaRespErrNoop
  toEnum (-140) = RdKafkaRespErrAutoOffsetReset
  toEnum (-100) = RdKafkaRespErrEnd
  toEnum (-1) = RdKafkaRespErrUnknown
  toEnum 0 = RdKafkaRespErrNoError
  toEnum 1 = RdKafkaRespErrOffsetOutOfRange
  toEnum 2 = RdKafkaRespErrInvalidMsg
  toEnum 3 = RdKafkaRespErrUnknownTopicOrPart
  toEnum 4 = RdKafkaRespErrInvalidMsgSize
  toEnum 5 = RdKafkaRespErrLeaderNotAvailable
  toEnum 6 = RdKafkaRespErrNotLeaderForPartition
  toEnum 7 = RdKafkaRespErrRequestTimedOut
  toEnum 8 = RdKafkaRespErrBrokerNotAvailable
  toEnum 9 = RdKafkaRespErrReplicaNotAvailable
  toEnum 10 = RdKafkaRespErrMsgSizeTooLarge
  toEnum 11 = RdKafkaRespErrStaleCtrlEpoch
  toEnum 12 = RdKafkaRespErrOffsetMetadataTooLarge
  toEnum 13 = RdKafkaRespErrNetworkException
  toEnum 14 = RdKafkaRespErrCoordinatorLoadInProgress
  toEnum 15 = RdKafkaRespErrCoordinatorNotAvailable
  toEnum 16 = RdKafkaRespErrNotCoordinator
  toEnum 17 = RdKafkaRespErrTopicException
  toEnum 18 = RdKafkaRespErrRecordListTooLarge
  toEnum 19 = RdKafkaRespErrNotEnoughReplicas
  toEnum 20 = RdKafkaRespErrNotEnoughReplicasAfterAppend
  toEnum 21 = RdKafkaRespErrInvalidRequiredAcks
  toEnum 22 = RdKafkaRespErrIllegalGeneration
  toEnum 23 = RdKafkaRespErrInconsistentGroupProtocol
  toEnum 24 = RdKafkaRespErrInvalidGroupId
  toEnum 25 = RdKafkaRespErrUnknownMemberId
  toEnum 26 = RdKafkaRespErrInvalidSessionTimeout
  toEnum 27 = RdKafkaRespErrRebalanceInProgress
  toEnum 28 = RdKafkaRespErrInvalidCommitOffsetSize
  toEnum 29 = RdKafkaRespErrTopicAuthorizationFailed
  toEnum 30 = RdKafkaRespErrGroupAuthorizationFailed
  toEnum 31 = RdKafkaRespErrClusterAuthorizationFailed
  toEnum 32 = RdKafkaRespErrInvalidTimestamp
  toEnum 33 = RdKafkaRespErrUnsupportedSaslMechanism
  toEnum 34 = RdKafkaRespErrIllegalSaslState
  toEnum 35 = RdKafkaRespErrUnsupportedVersion
  toEnum 36 = RdKafkaRespErrTopicAlreadyExists
  toEnum 37 = RdKafkaRespErrInvalidPartitions
  toEnum 38 = RdKafkaRespErrInvalidReplicationFactor
  toEnum 39 = RdKafkaRespErrInvalidReplicaAssignment
  toEnum 40 = RdKafkaRespErrInvalidConfig
  toEnum 41 = RdKafkaRespErrNotController
  toEnum 42 = RdKafkaRespErrInvalidRequest
  toEnum 43 = RdKafkaRespErrUnsupportedForMessageFormat
  toEnum 44 = RdKafkaRespErrPolicyViolation
  toEnum 45 = RdKafkaRespErrOutOfOrderSequenceNumber
  toEnum 46 = RdKafkaRespErrDuplicateSequenceNumber
  toEnum 47 = RdKafkaRespErrInvalidProducerEpoch
  toEnum 48 = RdKafkaRespErrInvalidTxnState
  toEnum 49 = RdKafkaRespErrInvalidProducerIdMapping
  toEnum 50 = RdKafkaRespErrInvalidTransactionTimeout
  toEnum 51 = RdKafkaRespErrConcurrentTransactions
  toEnum 52 = RdKafkaRespErrTransactionCoordinatorFenced
  toEnum 53 = RdKafkaRespErrTransactionalIdAuthorizationFailed
  toEnum 54 = RdKafkaRespErrSecurityDisabled
  toEnum 55 = RdKafkaRespErrOperationNotAttempted
  toEnum 56 = RdKafkaRespErrKafkaStorageError
  toEnum 57 = RdKafkaRespErrLogDirNotFound
  toEnum 58 = RdKafkaRespErrSaslAuthenticationFailed
  toEnum 59 = RdKafkaRespErrUnknownProducerId
  toEnum 60 = RdKafkaRespErrReassignmentInProgress
  toEnum 61 = RdKafkaRespErrDelegationTokenAuthDisabled
  toEnum 62 = RdKafkaRespErrDelegationTokenNotFound
  toEnum 63 = RdKafkaRespErrDelegationTokenOwnerMismatch
  toEnum 64 = RdKafkaRespErrDelegationTokenRequestNotAllowed
  toEnum 65 = RdKafkaRespErrDelegationTokenAuthorizationFailed
  toEnum 66 = RdKafkaRespErrDelegationTokenExpired
  toEnum 67 = RdKafkaRespErrInvalidPrincipalType
  toEnum 68 = RdKafkaRespErrNonEmptyGroup
  toEnum 69 = RdKafkaRespErrGroupIdNotFound
  toEnum 70 = RdKafkaRespErrFetchSessionIdNotFound
  toEnum 71 = RdKafkaRespErrInvalidFetchSessionEpoch
  toEnum 72 = RdKafkaRespErrListenerNotFound
  toEnum 73 = RdKafkaRespErrTopicDeletionDisabled
  toEnum 74 = RdKafkaRespErrFencedLeaderEpoch
  toEnum 75 = RdKafkaRespErrUnknownLeaderEpoch
  toEnum 76 = RdKafkaRespErrUnsupportedCompressionType
  toEnum 77 = RdKafkaRespErrStaleBrokerEpoch
  toEnum 78 = RdKafkaRespErrOffsetNotAvailable
  toEnum 79 = RdKafkaRespErrMemberIdRequired
  toEnum 80 = RdKafkaRespErrPreferredLeaderNotAvailable
  toEnum 81 = RdKafkaRespErrGroupMaxSizeReached
  toEnum 82 = RdKafkaRespErrFencedInstanceId
  toEnum 83 = RdKafkaRespErrEligibleLeadersNotAvailable
  toEnum 84 = RdKafkaRespErrElectionNotNeeded
  toEnum 85 = RdKafkaRespErrNoReassignmentInProgress
  toEnum 86 = RdKafkaRespErrGroupSubscribedToTopic
  toEnum 87 = RdKafkaRespErrInvalidRecord
  toEnum 88 = RdKafkaRespErrUnstableOffsetCommit
  toEnum 89 = RdKafkaRespErrThrottlingQuotaExceeded
  toEnum 90 = RdKafkaRespErrProducerFenced
  toEnum 91 = RdKafkaRespErrResourceNotFound
  toEnum 92 = RdKafkaRespErrDuplicateResource
  toEnum 93 = RdKafkaRespErrUnacceptableCredential
  toEnum 94 = RdKafkaRespErrInconsistentVoterSet
  toEnum 95 = RdKafkaRespErrInvalidUpdateVersion
  toEnum 96 = RdKafkaRespErrFeatureUpdateFailed
  toEnum 97 = RdKafkaRespErrPrincipalDeserializationFailure
  toEnum 98 = RdKafkaRespErrEndAll
  toEnum unmatched = error ("RdKafkaRespErrT.toEnum: Cannot match " ++ show unmatched)

{-# LINE 40 "src/Kafka/Internal/RdKafka.chs" #-}

data RdKafkaTimestampTypeT = RdKafkaTimestampNotAvailable
                           | RdKafkaTimestampCreateTime
                           | RdKafkaTimestampLogAppendTime
  deriving (Enum,Show,Eq)

{-# LINE 41 "src/Kafka/Internal/RdKafka.chs" #-}


type RdKafkaMsgFlag = Int
rdKafkaMsgFlagFree :: RdKafkaMsgFlag
rdKafkaMsgFlagFree = 0x1
rdKafkaMsgFlagCopy :: RdKafkaMsgFlag
rdKafkaMsgFlagCopy = 0x2

-- Number of bytes allocated for an error buffer
nErrorBytes ::  Int
nErrorBytes = 1024 * 8

-- Helper functions
rdKafkaVersion :: (Int)
rdKafkaVersion =
  C2HSImp.unsafePerformIO $
  rdKafkaVersion'_ >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 55 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaVersionStr :: (String)
rdKafkaVersionStr =
  C2HSImp.unsafePerformIO $
  rdKafkaVersionStr'_ >>= \res ->
  C2HSImp.peekCString res >>= \res' ->
  return (res')

{-# LINE 58 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaErr2str :: (RdKafkaRespErrT) -> (String)
rdKafkaErr2str a1 =
  C2HSImp.unsafePerformIO $
  let {a1' = enumToCInt a1} in 
  rdKafkaErr2str'_ a1' >>= \res ->
  C2HSImp.peekCString res >>= \res' ->
  return (res')

{-# LINE 61 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaErr2name :: (RdKafkaRespErrT) -> (String)
rdKafkaErr2name a1 =
  C2HSImp.unsafePerformIO $
  let {a1' = enumToCInt a1} in 
  rdKafkaErr2name'_ a1' >>= \res ->
  C2HSImp.peekCString res >>= \res' ->
  return (res')

{-# LINE 64 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaErrno2err :: (Int) -> (RdKafkaRespErrT)
rdKafkaErrno2err a1 =
  C2HSImp.unsafePerformIO $
  let {a1' = fromIntegral a1} in 
  rdKafkaErrno2err'_ a1' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 67 "src/Kafka/Internal/RdKafka.chs" #-}


peekCAText :: CString -> IO Text
peekCAText cp = Text.pack <$> peekCAString cp

peekCText :: CString -> IO Text
peekCText cp = Text.pack <$> peekCString cp

kafkaErrnoString :: IO String
kafkaErrnoString = do
    (Errno num) <- getErrno
    return $ rdKafkaErr2str $ rdKafkaErrno2err (fromIntegral num)

-- Kafka Pointer Types
data RdKafkaConfT
type RdKafkaConfTPtr = C2HSImp.ForeignPtr (RdKafkaConfT)
{-# LINE 82 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaTopicConfT
type RdKafkaTopicConfTPtr = C2HSImp.ForeignPtr (RdKafkaTopicConfT)
{-# LINE 85 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaT
type RdKafkaTPtr = C2HSImp.ForeignPtr (RdKafkaT)
{-# LINE 88 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaTopicPartitionT = RdKafkaTopicPartitionT
    { topic'RdKafkaTopicPartitionT :: CString
    , partition'RdKafkaTopicPartitionT :: Int
    , offset'RdKafkaTopicPartitionT :: Int64
    , metadata'RdKafkaTopicPartitionT :: Word8Ptr
    , metadataSize'RdKafkaTopicPartitionT :: Int
    , opaque'RdKafkaTopicPartitionT :: Word8Ptr
    , err'RdKafkaTopicPartitionT :: RdKafkaRespErrT
    } deriving (Show, Eq)

instance Storable RdKafkaTopicPartitionT where
    alignment _ = 8
{-# LINE 101 "src/Kafka/Internal/RdKafka.chs" #-}

    sizeOf _ = 64
{-# LINE 102 "src/Kafka/Internal/RdKafka.chs" #-}

    peek p = RdKafkaTopicPartitionT
        <$> liftM id           ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO C2HSImp.CInt}) p)
        <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO C2HSImp.CLLong}) p)
        <*> liftM castPtr      ((\ptr -> do {C2HSImp.peekByteOff ptr 24 :: IO (C2HSImp.Ptr ())}) p)
        <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 32 :: IO C2HSImp.CULong}) p)
        <*> liftM castPtr      ((\ptr -> do {C2HSImp.peekByteOff ptr 40 :: IO (C2HSImp.Ptr ())}) p)
        <*> liftM cIntToEnum   ((\ptr -> do {C2HSImp.peekByteOff ptr 48 :: IO C2HSImp.CInt}) p)
    poke p x = do
        (\ptr val -> do {C2HSImp.pokeByteOff ptr 0 (val :: (C2HSImp.Ptr C2HSImp.CChar))})         p (id           $ topic'RdKafkaTopicPartitionT x)
        (\ptr val -> do {C2HSImp.pokeByteOff ptr 8 (val :: C2HSImp.CInt)})     p (fromIntegral $ partition'RdKafkaTopicPartitionT x)
        (\ptr val -> do {C2HSImp.pokeByteOff ptr 16 (val :: C2HSImp.CLLong)})        p (fromIntegral $ offset'RdKafkaTopicPartitionT x)
        (\ptr val -> do {C2HSImp.pokeByteOff ptr 24 (val :: (C2HSImp.Ptr ()))})      p (castPtr      $ metadata'RdKafkaTopicPartitionT x)
        (\ptr val -> do {C2HSImp.pokeByteOff ptr 32 (val :: C2HSImp.CULong)}) p (fromIntegral $ metadataSize'RdKafkaTopicPartitionT x)
        (\ptr val -> do {C2HSImp.pokeByteOff ptr 40 (val :: (C2HSImp.Ptr ()))})        p (castPtr      $ opaque'RdKafkaTopicPartitionT x)
        (\ptr val -> do {C2HSImp.pokeByteOff ptr 48 (val :: C2HSImp.CInt)})           p (enumToCInt   $ err'RdKafkaTopicPartitionT x)

type RdKafkaTopicPartitionTPtr = C2HSImp.ForeignPtr (RdKafkaTopicPartitionT)
{-# LINE 120 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaTopicPartitionListT = RdKafkaTopicPartitionListT
    { cnt'RdKafkaTopicPartitionListT   :: Int
    , size'RdKafkaTopicPartitionListT  :: Int
    , elems'RdKafkaTopicPartitionListT :: Ptr RdKafkaTopicPartitionT
    } deriving (Show, Eq)

type RdKafkaTopicPartitionListTPtr = C2HSImp.ForeignPtr (RdKafkaTopicPartitionListT)
{-# LINE 128 "src/Kafka/Internal/RdKafka.chs" #-}


instance Storable RdKafkaTopicPartitionListT where
  alignment _ = 8
{-# LINE 131 "src/Kafka/Internal/RdKafka.chs" #-}

  sizeOf _    = 16
{-# LINE 132 "src/Kafka/Internal/RdKafka.chs" #-}

  peek p = RdKafkaTopicPartitionListT
    <$> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO C2HSImp.CInt}) p)
    <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 4 :: IO C2HSImp.CInt}) p)
    <*> liftM castPtr      ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr (RdKafkaTopicPartitionT))}) p)
  poke p x = do
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 0 (val :: C2HSImp.CInt)})   p (fromIntegral $ cnt'RdKafkaTopicPartitionListT x)
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 4 (val :: C2HSImp.CInt)})  p (fromIntegral $ size'RdKafkaTopicPartitionListT x)
    (\ptr val -> do {C2HSImp.pokeByteOff ptr 8 (val :: (C2HSImp.Ptr (RdKafkaTopicPartitionT)))}) p (castPtr      $ elems'RdKafkaTopicPartitionListT x)

data RdKafkaTopicT
type RdKafkaTopicTPtr = C2HSImp.ForeignPtr (RdKafkaTopicT)
{-# LINE 143 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaMessageT = RdKafkaMessageT
    { err'RdKafkaMessageT :: RdKafkaRespErrT
    , topic'RdKafkaMessageT :: Ptr RdKafkaTopicT
    , partition'RdKafkaMessageT :: Int
    , len'RdKafkaMessageT :: Int
    , keyLen'RdKafkaMessageT :: Int
    , offset'RdKafkaMessageT :: Int64
    , payload'RdKafkaMessageT :: Word8Ptr
    , key'RdKafkaMessageT :: Word8Ptr
    , opaque'RdKafkaMessageT :: Ptr ()
    }
    deriving (Show, Eq)

instance Storable RdKafkaMessageT where
    alignment _ = 8
{-# LINE 159 "src/Kafka/Internal/RdKafka.chs" #-}

    sizeOf _ = 72
{-# LINE 160 "src/Kafka/Internal/RdKafka.chs" #-}

    peek p = RdKafkaMessageT
        <$> liftM cIntToEnum    ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO C2HSImp.CInt}) p)
        <*> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr (RdKafkaTopicT))}) p)
        <*> liftM fromIntegral  ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO C2HSImp.CInt}) p)
        <*> liftM fromIntegral  ((\ptr -> do {C2HSImp.peekByteOff ptr 32 :: IO C2HSImp.CULong}) p)
        <*> liftM fromIntegral  ((\ptr -> do {C2HSImp.peekByteOff ptr 48 :: IO C2HSImp.CULong}) p)
        <*> liftM fromIntegral  ((\ptr -> do {C2HSImp.peekByteOff ptr 56 :: IO C2HSImp.CLLong}) p)
        <*> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 24 :: IO (C2HSImp.Ptr ())}) p)
        <*> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 40 :: IO (C2HSImp.Ptr ())}) p)
        <*> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 64 :: IO (C2HSImp.Ptr ())}) p)
    poke p x = do
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 0 (val :: C2HSImp.CInt)})        p (enumToCInt   $ err'RdKafkaMessageT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 8 (val :: (C2HSImp.Ptr (RdKafkaTopicT)))})        p (castPtr      $ topic'RdKafkaMessageT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 16 (val :: C2HSImp.CInt)})  p (fromIntegral $ partition'RdKafkaMessageT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 32 (val :: C2HSImp.CULong)})        p (fromIntegral $ len'RdKafkaMessageT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 48 (val :: C2HSImp.CULong)})    p (fromIntegral $ keyLen'RdKafkaMessageT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 56 (val :: C2HSImp.CLLong)})     p (fromIntegral $ offset'RdKafkaMessageT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 24 (val :: (C2HSImp.Ptr ()))})    p (castPtr      $ payload'RdKafkaMessageT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 40 (val :: (C2HSImp.Ptr ()))})        p (castPtr      $ key'RdKafkaMessageT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 64 (val :: (C2HSImp.Ptr ()))})   p (castPtr      $ opaque'RdKafkaMessageT x)

type RdKafkaMessageTPtr = C2HSImp.ForeignPtr (RdKafkaMessageT)
{-# LINE 182 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaMetadataBrokerT = RdKafkaMetadataBrokerT
  { id'RdKafkaMetadataBrokerT  :: Int
  , host'RdKafkaMetadataBrokerT :: CString
  , port'RdKafkaMetadataBrokerT :: Int
  } deriving (Show, Eq)

type RdKafkaMetadataBrokerTPtr = C2HSImp.Ptr (RdKafkaMetadataBrokerT)
{-# LINE 190 "src/Kafka/Internal/RdKafka.chs" #-}



instance Storable RdKafkaMetadataBrokerT where
  alignment _ = 8
{-# LINE 194 "src/Kafka/Internal/RdKafka.chs" #-}

  sizeOf _ = 24
{-# LINE 195 "src/Kafka/Internal/RdKafka.chs" #-}

  peek p = RdKafkaMetadataBrokerT
    <$> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO C2HSImp.CInt}) p)
    <*> liftM id ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
    <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO C2HSImp.CInt}) p)
  poke = undefined

data RdKafkaMetadataPartitionT = RdKafkaMetadataPartitionT
  { id'RdKafkaMetadataPartitionT :: Int
  , err'RdKafkaMetadataPartitionT :: RdKafkaRespErrT
  , leader'RdKafkaMetadataPartitionT :: Int
  , replicaCnt'RdKafkaMetadataPartitionT :: Int
  , replicas'RdKafkaMetadataPartitionT :: Ptr CInt32T
  , isrCnt'RdKafkaMetadataPartitionT :: Int
  , isrs'RdKafkaMetadataPartitionT :: Ptr CInt32T
  } deriving (Show, Eq)

instance Storable RdKafkaMetadataPartitionT where
  alignment _ = 8
{-# LINE 213 "src/Kafka/Internal/RdKafka.chs" #-}

  sizeOf _ = 40
{-# LINE 214 "src/Kafka/Internal/RdKafka.chs" #-}

  peek p = RdKafkaMetadataPartitionT
    <$> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO C2HSImp.CInt}) p)
    <*> liftM cIntToEnum ((\ptr -> do {C2HSImp.peekByteOff ptr 4 :: IO C2HSImp.CInt}) p)
    <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO C2HSImp.CInt}) p)
    <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 12 :: IO C2HSImp.CInt}) p)
    <*> liftM castPtr ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO (C2HSImp.Ptr C2HSImp.CInt)}) p)
    <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 24 :: IO C2HSImp.CInt}) p)
    <*> liftM castPtr ((\ptr -> do {C2HSImp.peekByteOff ptr 32 :: IO (C2HSImp.Ptr C2HSImp.CInt)}) p)

  poke = undefined

type RdKafkaMetadataPartitionTPtr = C2HSImp.Ptr (RdKafkaMetadataPartitionT)
{-# LINE 226 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaMetadataTopicT = RdKafkaMetadataTopicT
  { topic'RdKafkaMetadataTopicT :: CString
  , partitionCnt'RdKafkaMetadataTopicT :: Int
  , partitions'RdKafkaMetadataTopicT :: Ptr RdKafkaMetadataPartitionT
  , err'RdKafkaMetadataTopicT :: RdKafkaRespErrT
  } deriving (Show, Eq)

instance Storable RdKafkaMetadataTopicT where
  alignment _ = 8
{-# LINE 236 "src/Kafka/Internal/RdKafka.chs" #-}

  sizeOf _ = 32
{-# LINE 237 "src/Kafka/Internal/RdKafka.chs" #-}

  peek p = RdKafkaMetadataTopicT
    <$> liftM id ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
    <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO C2HSImp.CInt}) p)
    <*> liftM castPtr ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO (C2HSImp.Ptr ())}) p)
    <*> liftM cIntToEnum ((\ptr -> do {C2HSImp.peekByteOff ptr 24 :: IO C2HSImp.CInt}) p)
  poke _ _ = undefined

type RdKafkaMetadataTopicTPtr = C2HSImp.Ptr (RdKafkaMetadataTopicT)
{-# LINE 245 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaMetadataT = RdKafkaMetadataT
  { brokerCnt'RdKafkaMetadataT :: Int
  , brokers'RdKafkaMetadataT :: RdKafkaMetadataBrokerTPtr
  , topicCnt'RdKafkaMetadataT :: Int
  , topics'RdKafkaMetadataT :: RdKafkaMetadataTopicTPtr
  , origBrokerId'RdKafkaMetadataT :: CInt32T
  } deriving (Show, Eq)

instance Storable RdKafkaMetadataT where
  alignment _ = 8
{-# LINE 256 "src/Kafka/Internal/RdKafka.chs" #-}

  sizeOf _ = 48
{-# LINE 257 "src/Kafka/Internal/RdKafka.chs" #-}

  peek p = RdKafkaMetadataT
    <$> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO C2HSImp.CInt}) p)
    <*> liftM castPtr ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr ())}) p)
    <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO C2HSImp.CInt}) p)
    <*> liftM castPtr ((\ptr -> do {C2HSImp.peekByteOff ptr 24 :: IO (C2HSImp.Ptr ())}) p)
    <*> liftM fromIntegral ((\ptr -> do {C2HSImp.peekByteOff ptr 32 :: IO C2HSImp.CInt}) p)
  poke _ _ = undefined

type RdKafkaMetadataTPtr = C2HSImp.ForeignPtr (RdKafkaMetadataT)
{-# LINE 266 "src/Kafka/Internal/RdKafka.chs" #-}


-------------------------------------------------------------------------------------------------
---- Partitions
rdKafkaTopicPartitionListNew :: (Int) -> IO ((RdKafkaTopicPartitionListTPtr))
rdKafkaTopicPartitionListNew a1 =
  let {a1' = fromIntegral a1} in 
  rdKafkaTopicPartitionListNew'_ a1' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 271 "src/Kafka/Internal/RdKafka.chs" #-}


foreign import ccall unsafe "rdkafka.h &rd_kafka_topic_partition_list_destroy"
    rdKafkaTopicPartitionListDestroyF :: FinalizerPtr RdKafkaTopicPartitionListT
foreign import ccall unsafe "rdkafka.h rd_kafka_topic_partition_list_destroy"
    rdKafkaTopicPartitionListDestroy :: Ptr RdKafkaTopicPartitionListT -> IO ()

newRdKafkaTopicPartitionListT :: Int -> IO RdKafkaTopicPartitionListTPtr
newRdKafkaTopicPartitionListT size = do
    ret <- rdKafkaTopicPartitionListNew size
    addForeignPtrFinalizer rdKafkaTopicPartitionListDestroyF ret
    return ret

rdKafkaTopicPartitionListAdd :: (RdKafkaTopicPartitionListTPtr) -> (String) -> (Int) -> IO ((RdKafkaTopicPartitionTPtr))
rdKafkaTopicPartitionListAdd a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  let {a3' = fromIntegral a3} in 
  rdKafkaTopicPartitionListAdd'_ a1' a2' a3' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 285 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaTopicPartitionListAddRange :: (RdKafkaTopicPartitionListTPtr) -> (String) -> (Int) -> (Int) -> IO ()
rdKafkaTopicPartitionListAddRange a1 a2 a3 a4 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  rdKafkaTopicPartitionListAddRange'_ a1' a2' a3' a4' >>
  return ()

{-# LINE 288 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaTopicPartitionListCopy :: (RdKafkaTopicPartitionListTPtr) -> IO ((RdKafkaTopicPartitionListTPtr))
rdKafkaTopicPartitionListCopy a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaTopicPartitionListCopy'_ a1' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 291 "src/Kafka/Internal/RdKafka.chs" #-}


copyRdKafkaTopicPartitionList :: RdKafkaTopicPartitionListTPtr -> IO RdKafkaTopicPartitionListTPtr
copyRdKafkaTopicPartitionList pl = do
    cp <- rdKafkaTopicPartitionListCopy pl
    addForeignPtrFinalizer rdKafkaTopicPartitionListDestroyF cp
    return cp

rdKafkaTopicPartitionListSetOffset :: (RdKafkaTopicPartitionListTPtr) -> (String) -> (Int) -> (Int64) -> IO ((RdKafkaRespErrT))
rdKafkaTopicPartitionListSetOffset a1 a2 a3 a4 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  rdKafkaTopicPartitionListSetOffset'_ a1' a2' a3' a4' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 301 "src/Kafka/Internal/RdKafka.chs" #-}


---- Rebalance Callback
type RdRebalanceCallback' = Ptr RdKafkaT -> CInt -> Ptr RdKafkaTopicPartitionListT -> Ptr Word8 -> IO ()
type RdRebalanceCallback = Ptr RdKafkaT -> RdKafkaRespErrT -> Ptr RdKafkaTopicPartitionListT -> IO ()

foreign import ccall safe "wrapper"
    mkRebalanceCallback :: RdRebalanceCallback' -> IO (FunPtr RdRebalanceCallback')

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_rebalance_cb"
     rdKafkaConfSetRebalanceCb' ::
       Ptr RdKafkaConfT
       -> FunPtr RdRebalanceCallback'
       -> IO ()

rdKafkaConfSetRebalanceCb :: RdKafkaConfTPtr -> RdRebalanceCallback -> IO ()
rdKafkaConfSetRebalanceCb conf cb = do
    cb' <- mkRebalanceCallback (\k e p _ -> cb k (cIntToEnum e) p)
    withForeignPtr conf $ \c -> rdKafkaConfSetRebalanceCb' c cb'
    return ()

---- Delivery Callback
type DeliveryCallback' = Ptr RdKafkaT -> Ptr RdKafkaMessageT -> Word8Ptr -> IO ()
type DeliveryCallback = Ptr RdKafkaT -> Ptr RdKafkaMessageT -> IO ()

foreign import ccall safe "wrapper"
    mkDeliveryCallback :: DeliveryCallback' -> IO (FunPtr DeliveryCallback')

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_dr_msg_cb"
    rdKafkaConfSetDrMsgCb' :: Ptr RdKafkaConfT -> FunPtr DeliveryCallback' -> IO ()

rdKafkaConfSetDrMsgCb :: RdKafkaConfTPtr -> DeliveryCallback -> IO ()
rdKafkaConfSetDrMsgCb conf cb = do
    cb' <- mkDeliveryCallback (\k m _ -> cb k m)
    withForeignPtr conf $ \c -> rdKafkaConfSetDrMsgCb' c cb'
    return ()

---- Consume Callback
type ConsumeCallback = Ptr RdKafkaMessageT -> Word8Ptr -> IO ()

foreign import ccall safe "wrapper"
    mkConsumeCallback :: ConsumeCallback -> IO (FunPtr ConsumeCallback)

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_consume_cb"
    rdKafkaConfSetConsumeCb' :: Ptr RdKafkaConfT -> FunPtr ConsumeCallback -> IO ()

rdKafkaConfSetConsumeCb :: RdKafkaConfTPtr -> ConsumeCallback -> IO ()
rdKafkaConfSetConsumeCb conf cb = do
    cb' <- mkConsumeCallback cb
    withForeignPtr conf $ \c -> rdKafkaConfSetConsumeCb' c cb'
    return ()

---- Offset Commit Callback
type OffsetCommitCallback' = Ptr RdKafkaT -> CInt -> Ptr RdKafkaTopicPartitionListT -> Word8Ptr -> IO ()
type OffsetCommitCallback  = Ptr RdKafkaT -> RdKafkaRespErrT -> Ptr RdKafkaTopicPartitionListT -> IO ()

foreign import ccall safe "wrapper"
    mkOffsetCommitCallback :: OffsetCommitCallback' -> IO (FunPtr OffsetCommitCallback')

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_offset_commit_cb"
    rdKafkaConfSetOffsetCommitCb' :: Ptr RdKafkaConfT -> FunPtr OffsetCommitCallback' -> IO ()

rdKafkaConfSetOffsetCommitCb :: RdKafkaConfTPtr -> OffsetCommitCallback -> IO ()
rdKafkaConfSetOffsetCommitCb conf cb = do
    cb' <- mkOffsetCommitCallback (\k e p _ -> cb k (cIntToEnum e) p)
    withForeignPtr conf $ \c -> rdKafkaConfSetOffsetCommitCb' c cb'
    return ()


----- Error Callback
type ErrorCallback' = Ptr RdKafkaT -> CInt -> CString -> Word8Ptr -> IO ()
type ErrorCallback  = Ptr RdKafkaT -> RdKafkaRespErrT -> String -> IO ()

foreign import ccall safe "wrapper"
    mkErrorCallback :: ErrorCallback' -> IO (FunPtr ErrorCallback')

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_error_cb"
    rdKafkaConfSetErrorCb' :: Ptr RdKafkaConfT -> FunPtr ErrorCallback' -> IO ()

rdKafkaConfSetErrorCb :: RdKafkaConfTPtr -> ErrorCallback -> IO ()
rdKafkaConfSetErrorCb conf cb = do
    cb' <- mkErrorCallback (\k e r _ -> peekCAString r >>= cb k (cIntToEnum e))
    withForeignPtr conf $ \c -> rdKafkaConfSetErrorCb' c cb'

---- Throttle Callback
type ThrottleCallback = Ptr RdKafkaT -> CString -> Int -> Int -> Word8Ptr -> IO ()

foreign import ccall safe "wrapper"
    mkThrottleCallback :: ThrottleCallback -> IO (FunPtr ThrottleCallback)

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_throttle_cb"
    rdKafkaConfSetThrottleCb' :: Ptr RdKafkaConfT -> FunPtr ThrottleCallback -> IO ()

rdKafkaConfSetThrottleCb :: RdKafkaConfTPtr -> ThrottleCallback -> IO ()
rdKafkaConfSetThrottleCb conf cb = do
    cb' <- mkThrottleCallback cb
    withForeignPtr conf $ \c -> rdKafkaConfSetThrottleCb' c cb'
    return ()

---- Log Callback
type LogCallback' = Ptr RdKafkaT -> CInt -> CString -> CString -> IO ()
type LogCallback = Ptr RdKafkaT -> Int -> String -> String -> IO ()

foreign import ccall safe "wrapper"
    mkLogCallback :: LogCallback' -> IO (FunPtr LogCallback')

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_log_cb"
    rdKafkaConfSetLogCb' :: Ptr RdKafkaConfT -> FunPtr LogCallback' -> IO ()

rdKafkaConfSetLogCb :: RdKafkaConfTPtr -> LogCallback -> IO ()
rdKafkaConfSetLogCb conf cb = do
    cb' <- mkLogCallback $ \k l f b -> do
            f' <- peekCAString f
            b' <- peekCAString b
            cb k (cIntConv l) f' b'
    withForeignPtr conf $ \c -> rdKafkaConfSetLogCb' c cb'

---- Stats Callback
type StatsCallback' = Ptr RdKafkaT -> CString -> CSize -> Word8Ptr -> IO CInt
type StatsCallback = Ptr RdKafkaT -> ByteString -> IO ()

foreign import ccall safe "wrapper"
    mkStatsCallback :: StatsCallback' -> IO (FunPtr StatsCallback')

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_stats_cb"
    rdKafkaConfSetStatsCb' :: Ptr RdKafkaConfT -> FunPtr StatsCallback' -> IO ()

rdKafkaConfSetStatsCb :: RdKafkaConfTPtr -> StatsCallback -> IO ()
rdKafkaConfSetStatsCb conf cb = do
    cb' <- mkStatsCallback $ \k j jl _ -> BS.packCStringLen (j, cIntConv jl) >>= cb k >> pure 0
    withForeignPtr conf $ \c -> rdKafkaConfSetStatsCb' c cb'
    return ()

---- Socket Callback
type SocketCallback = Int -> Int -> Int -> Word8Ptr -> IO CInt

foreign import ccall safe "wrapper"
    mkSocketCallback :: SocketCallback -> IO (FunPtr SocketCallback)

foreign import ccall safe "rd_kafka.h rd_kafka_conf_set_socket_cb"
    rdKafkaConfSetSocketCb' :: Ptr RdKafkaConfT -> FunPtr SocketCallback -> IO ()

rdKafkaConfSetSocketCb :: RdKafkaConfTPtr -> SocketCallback -> IO ()
rdKafkaConfSetSocketCb conf cb = do
    cb' <- mkSocketCallback cb
    withForeignPtr conf $ \c -> rdKafkaConfSetSocketCb' c cb' >> pure 0
    return ()

rdKafkaConfSetOpaque :: (RdKafkaConfTPtr) -> (Word8Ptr) -> IO ()
rdKafkaConfSetOpaque a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = castPtr a2} in 
  rdKafkaConfSetOpaque'_ a1' a2' >>
  return ()

{-# LINE 450 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaOpaque :: (RdKafkaTPtr) -> IO ((Word8Ptr))
rdKafkaOpaque a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaOpaque'_ a1' >>= \res ->
  let {res' = castPtr res} in
  return (res')

{-# LINE 453 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConfSetDefaultTopicConf :: (RdKafkaConfTPtr) -> (RdKafkaTopicConfTPtr) -> IO ()
rdKafkaConfSetDefaultTopicConf a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaConfSetDefaultTopicConf'_ a1' a2' >>
  return ()

{-# LINE 456 "src/Kafka/Internal/RdKafka.chs" #-}


---- Partitioner Callback
type PartitionerCallback =
    Ptr RdKafkaTopicTPtr
    -> Word8Ptr    -- keydata
    -> Int         -- keylen
    -> Int         -- partition_cnt
    -> Word8Ptr    -- topic_opaque
    -> Word8Ptr    -- msg_opaque
    -> IO Int

foreign import ccall safe "wrapper"
    mkPartitionerCallback :: PartitionerCallback -> IO (FunPtr PartitionerCallback)

foreign import ccall safe "rd_kafka.h rd_kafka_topic_conf_set_partitioner_cb"
    rdKafkaTopicConfSetPartitionerCb' :: Ptr RdKafkaTopicConfT -> FunPtr PartitionerCallback -> IO ()

rdKafkaTopicConfSetPartitionerCb :: RdKafkaTopicConfTPtr -> PartitionerCallback -> IO ()
rdKafkaTopicConfSetPartitionerCb conf cb = do
    cb' <- mkPartitionerCallback cb
    withForeignPtr conf $ \c -> rdKafkaTopicConfSetPartitionerCb' c cb'
    return ()

---- Partition

rdKafkaTopicPartitionAvailable :: (RdKafkaTopicTPtr) -> (CInt32T) -> IO ((Int))
rdKafkaTopicPartitionAvailable a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = cIntConv a2} in 
  rdKafkaTopicPartitionAvailable'_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 483 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaMsgPartitionerRandom :: (RdKafkaTopicTPtr) -> (Word8Ptr) -> (CSize) -> (CInt32T) -> (Word8Ptr) -> (Word8Ptr) -> IO ((CInt32T))
rdKafkaMsgPartitionerRandom a1 a2 a3 a4 a5 a6 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = castPtr a2} in 
  let {a3' = cIntConv a3} in 
  let {a4' = cIntConv a4} in 
  let {a5' = castPtr a5} in 
  let {a6' = castPtr a6} in 
  rdKafkaMsgPartitionerRandom'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = cIntConv res} in
  return (res')

{-# LINE 492 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaMsgPartitionerConsistent :: (RdKafkaTopicTPtr) -> (Word8Ptr) -> (CSize) -> (CInt32T) -> (Word8Ptr) -> (Word8Ptr) -> IO ((CInt32T))
rdKafkaMsgPartitionerConsistent a1 a2 a3 a4 a5 a6 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = castPtr a2} in 
  let {a3' = cIntConv a3} in 
  let {a4' = cIntConv a4} in 
  let {a5' = castPtr a5} in 
  let {a6' = castPtr a6} in 
  rdKafkaMsgPartitionerConsistent'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = cIntConv res} in
  return (res')

{-# LINE 501 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaMsgPartitionerConsistentRandom :: (RdKafkaTopicTPtr) -> (Word8Ptr) -> (CSize) -> (CInt32T) -> (Word8Ptr) -> (Word8Ptr) -> IO ((CInt32T))
rdKafkaMsgPartitionerConsistentRandom a1 a2 a3 a4 a5 a6 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = castPtr a2} in 
  let {a3' = cIntConv a3} in 
  let {a4' = cIntConv a4} in 
  let {a5' = castPtr a5} in 
  let {a6' = castPtr a6} in 
  rdKafkaMsgPartitionerConsistentRandom'_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = cIntConv res} in
  return (res')

{-# LINE 510 "src/Kafka/Internal/RdKafka.chs" #-}


---- Poll / Yield

rdKafkaYield :: (RdKafkaTPtr) -> IO ()
rdKafkaYield a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaYield'_ a1' >>
  return ()

{-# LINE 515 "src/Kafka/Internal/RdKafka.chs" #-}


---- Pause / Resume
rdKafkaPausePartitions :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaPausePartitions a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaPausePartitions'_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 519 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaResumePartitions :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaResumePartitions a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaResumePartitions'_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 522 "src/Kafka/Internal/RdKafka.chs" #-}


---- QUEUE
data RdKafkaQueueT
type RdKafkaQueueTPtr = C2HSImp.ForeignPtr (RdKafkaQueueT)
{-# LINE 526 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaQueueNew :: (RdKafkaTPtr) -> IO ((RdKafkaQueueTPtr))
rdKafkaQueueNew a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaQueueNew'_ a1' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 529 "src/Kafka/Internal/RdKafka.chs" #-}


foreign import ccall unsafe "rdkafka.h &rd_kafka_queue_destroy"
    rdKafkaQueueDestroyF :: FinalizerPtr RdKafkaQueueT

rdKafkaQueueDestroy :: (RdKafkaQueueTPtr) -> IO ()
rdKafkaQueueDestroy a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaQueueDestroy'_ a1' >>
  return ()

{-# LINE 535 "src/Kafka/Internal/RdKafka.chs" #-}


newRdKafkaQueue :: RdKafkaTPtr -> IO RdKafkaQueueTPtr
newRdKafkaQueue k = do
    q <- rdKafkaQueueNew k
    addForeignPtrFinalizer rdKafkaQueueDestroyF q
    return q

rdKafkaConsumeQueue :: (RdKafkaQueueTPtr) -> (Int) -> IO ((RdKafkaMessageTPtr))
rdKafkaConsumeQueue a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  rdKafkaConsumeQueue'_ a1' a2' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 544 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaQueueForward :: (RdKafkaQueueTPtr) -> (RdKafkaQueueTPtr) -> IO ()
rdKafkaQueueForward a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaQueueForward'_ a1' a2' >>
  return ()

{-# LINE 547 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaQueueGetPartition' :: (RdKafkaTPtr) -> (String) -> (Int) -> IO ((RdKafkaQueueTPtr))
rdKafkaQueueGetPartition' a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  let {a3' = fromIntegral a3} in 
  rdKafkaQueueGetPartition''_ a1' a2' a3' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 550 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaQueueGetPartition :: RdKafkaTPtr -> String -> Int -> IO (Maybe RdKafkaQueueTPtr)
rdKafkaQueueGetPartition k t p = do
    ret <- rdKafkaQueueGetPartition' k t p
    withForeignPtr ret $ \realPtr ->
        if realPtr == nullPtr then return Nothing
        else do
            addForeignPtrFinalizer rdKafkaQueueDestroyF ret
            return $ Just ret

rdKafkaConsumeBatchQueue' :: (RdKafkaQueueTPtr) -> (Int) -> (Ptr (Ptr RdKafkaMessageT)) -> (CSize) -> IO ((CSize))
rdKafkaConsumeBatchQueue' a1 a2 a3 a4 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  let {a3' = castPtr a3} in 
  let {a4' = cIntConv a4} in 
  rdKafkaConsumeBatchQueue''_ a1' a2' a3' a4' >>= \res ->
  let {res' = cIntConv res} in
  return (res')

{-# LINE 563 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConsumeBatchQueue :: RdKafkaQueueTPtr -> Int -> Int -> IO [RdKafkaMessageTPtr]
rdKafkaConsumeBatchQueue qptr timeout batchSize = do
  allocaArray batchSize $ \pArr -> do
    rSize <- rdKafkaConsumeBatchQueue' qptr timeout pArr (fromIntegral batchSize)
    peekArray (fromIntegral rSize) pArr >>= traverse (flip newForeignPtr (return ()))

-------------------------------------------------------------------------------------------------
---- High-level KafkaConsumer

rdKafkaSubscribe :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaSubscribe a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaSubscribe'_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 576 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaUnsubscribe :: (RdKafkaTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaUnsubscribe a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaUnsubscribe'_ a1' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 580 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaSubscription' :: (RdKafkaTPtr) -> IO ((RdKafkaRespErrT), (Ptr RdKafkaTopicPartitionListT))
rdKafkaSubscription' a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  alloca $ \a2' -> 
  rdKafkaSubscription''_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  peekPtr  a2'>>= \a2'' -> 
  return (res', a2'')

{-# LINE 584 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaSubscription :: RdKafkaTPtr -> IO (Either RdKafkaRespErrT RdKafkaTopicPartitionListTPtr)
rdKafkaSubscription k = do
    (err, sub) <- rdKafkaSubscription' k
    case err of
        RdKafkaRespErrNoError ->
            Right <$> newForeignPtr sub (rdKafkaTopicPartitionListDestroy sub)
        e -> return (Left e)

rdKafkaConsumerPoll :: (RdKafkaTPtr) -> (Int) -> IO ((RdKafkaMessageTPtr))
rdKafkaConsumerPoll a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  rdKafkaConsumerPoll'_ a1' a2' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 595 "src/Kafka/Internal/RdKafka.chs" #-}


pollRdKafkaConsumer :: RdKafkaTPtr -> Int -> IO RdKafkaMessageTPtr
pollRdKafkaConsumer k t = do
    m <- rdKafkaConsumerPoll k t
    addForeignPtrFinalizer rdKafkaMessageDestroyF m
    return m

rdKafkaConsumerClose :: (RdKafkaTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaConsumerClose a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaConsumerClose'_ a1' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 604 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaPollSetConsumer :: (RdKafkaTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaPollSetConsumer a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaPollSetConsumer'_ a1' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 607 "src/Kafka/Internal/RdKafka.chs" #-}


-- rd_kafka_assign
rdKafkaAssign :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaAssign a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaAssign'_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 612 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaAssignment' :: (RdKafkaTPtr) -> IO ((RdKafkaRespErrT), (Ptr RdKafkaTopicPartitionListT))
rdKafkaAssignment' a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  alloca $ \a2' -> 
  rdKafkaAssignment''_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  peekPtr  a2'>>= \a2'' -> 
  return (res', a2'')

{-# LINE 616 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaAssignment :: RdKafkaTPtr -> IO (Either RdKafkaRespErrT RdKafkaTopicPartitionListTPtr)
rdKafkaAssignment k = do
    (err, ass) <- rdKafkaAssignment' k
    case err of
        RdKafkaRespErrNoError ->
            Right <$> newForeignPtr ass (rdKafkaTopicPartitionListDestroy ass)
        e -> return (Left e)

rdKafkaCommit :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> (Bool) -> IO ((RdKafkaRespErrT))
rdKafkaCommit a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  let {a3' = boolToCInt a3} in 
  rdKafkaCommit'_ a1' a2' a3' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 628 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaCommitMessage :: (RdKafkaTPtr) -> (RdKafkaMessageTPtr) -> (Bool) -> IO ((RdKafkaRespErrT))
rdKafkaCommitMessage a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  let {a3' = boolToCInt a3} in 
  rdKafkaCommitMessage'_ a1' a2' a3' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 632 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaCommitted :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> (Int) -> IO ((RdKafkaRespErrT))
rdKafkaCommitted a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  let {a3' = fromIntegral a3} in 
  rdKafkaCommitted'_ a1' a2' a3' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 636 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaPosition :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaPosition a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaPosition'_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 640 "src/Kafka/Internal/RdKafka.chs" #-}


-------------------------------------------------------------------------------------------------
---- Groups
data RdKafkaGroupMemberInfoT = RdKafkaGroupMemberInfoT
    { memberId'RdKafkaGroupMemberInfoT              :: CString
    , clientId'RdKafkaGroupMemberInfoT              :: CString
    , clientHost'RdKafkaGroupMemberInfoT            :: CString
    , memberMetadata'RdKafkaGroupMemberInfoT        :: Word8Ptr
    , memberMetadataSize'RdKafkaGroupMemberInfoT    :: Int
    , memberAssignment'RdKafkaGroupMemberInfoT      :: Word8Ptr
    , memberAssignmentSize'RdKafkaGroupMemberInfoT  :: Int }

instance Storable RdKafkaGroupMemberInfoT where
    alignment _ = 8
{-# LINE 654 "src/Kafka/Internal/RdKafka.chs" #-}

    sizeOf _ = 56
{-# LINE 655 "src/Kafka/Internal/RdKafka.chs" #-}

    peek p = RdKafkaGroupMemberInfoT
        <$> liftM id            ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        <*> liftM id            ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        <*> liftM id            ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        <*> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 24 :: IO (C2HSImp.Ptr ())}) p)
        <*> liftM fromIntegral  ((\ptr -> do {C2HSImp.peekByteOff ptr 32 :: IO C2HSImp.CInt}) p)
        <*> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 40 :: IO (C2HSImp.Ptr ())}) p)
        <*> liftM fromIntegral  ((\ptr -> do {C2HSImp.peekByteOff ptr 48 :: IO C2HSImp.CInt}) p)
    poke p x = do
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 0 (val :: (C2HSImp.Ptr C2HSImp.CChar))})              p (id           $ memberId'RdKafkaGroupMemberInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 8 (val :: (C2HSImp.Ptr C2HSImp.CChar))})              p (id           $ clientId'RdKafkaGroupMemberInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 16 (val :: (C2HSImp.Ptr C2HSImp.CChar))})            p (id           $ clientHost'RdKafkaGroupMemberInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 24 (val :: (C2HSImp.Ptr ()))})        p (castPtr      $ memberMetadata'RdKafkaGroupMemberInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 32 (val :: C2HSImp.CInt)})   p (fromIntegral $ memberMetadataSize'RdKafkaGroupMemberInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 40 (val :: (C2HSImp.Ptr ()))})      p (castPtr      $ memberAssignment'RdKafkaGroupMemberInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 48 (val :: C2HSImp.CInt)}) p (fromIntegral $ memberAssignmentSize'RdKafkaGroupMemberInfoT x)

type RdKafkaGroupMemberInfoTPtr = C2HSImp.Ptr (RdKafkaGroupMemberInfoT)
{-# LINE 673 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaGroupInfoT = RdKafkaGroupInfoT
    { broker'RdKafkaGroupInfoT       :: RdKafkaMetadataBrokerTPtr
    , group'RdKafkaGroupInfoT        :: CString
    , err'RdKafkaGroupInfoT          :: RdKafkaRespErrT
    , state'RdKafkaGroupInfoT        :: CString
    , protocolType'RdKafkaGroupInfoT :: CString
    , protocol'RdKafkaGroupInfoT     :: CString
    , members'RdKafkaGroupInfoT      :: RdKafkaGroupMemberInfoTPtr
    , memberCnt'RdKafkaGroupInfoT    :: Int }

instance Storable RdKafkaGroupInfoT where
    alignment _ = 8
{-# LINE 686 "src/Kafka/Internal/RdKafka.chs" #-}

    sizeOf _ = 80
{-# LINE 687 "src/Kafka/Internal/RdKafka.chs" #-}

    peek p = RdKafkaGroupInfoT
        <$> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO (C2HSImp.Ptr ())}) p)
        <*> liftM id            ((\ptr -> do {C2HSImp.peekByteOff ptr 24 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        <*> liftM cIntToEnum    ((\ptr -> do {C2HSImp.peekByteOff ptr 32 :: IO C2HSImp.CInt}) p)
        <*> liftM id            ((\ptr -> do {C2HSImp.peekByteOff ptr 40 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        <*> liftM id            ((\ptr -> do {C2HSImp.peekByteOff ptr 48 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        <*> liftM id            ((\ptr -> do {C2HSImp.peekByteOff ptr 56 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        <*> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 64 :: IO (RdKafkaGroupMemberInfoTPtr)}) p)
        <*> liftM fromIntegral  ((\ptr -> do {C2HSImp.peekByteOff ptr 72 :: IO C2HSImp.CInt}) p)
    poke p x = do
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 0 (val :: (C2HSImp.Ptr ()))})        p (castPtr      $ broker'RdKafkaGroupInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 24 (val :: (C2HSImp.Ptr C2HSImp.CChar))})         p (id           $ group'RdKafkaGroupInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 32 (val :: C2HSImp.CInt)})           p (enumToCInt   $ err'RdKafkaGroupInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 40 (val :: (C2HSImp.Ptr C2HSImp.CChar))})         p (id           $ state'RdKafkaGroupInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 48 (val :: (C2HSImp.Ptr C2HSImp.CChar))}) p (id           $ protocolType'RdKafkaGroupInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 56 (val :: (C2HSImp.Ptr C2HSImp.CChar))})      p (id           $ protocol'RdKafkaGroupInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 64 (val :: (RdKafkaGroupMemberInfoTPtr))})       p (castPtr      $ members'RdKafkaGroupInfoT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 72 (val :: C2HSImp.CInt)})    p (fromIntegral $ memberCnt'RdKafkaGroupInfoT x)

type RdKafkaGroupInfoTPtr = C2HSImp.ForeignPtr (RdKafkaGroupInfoT)
{-# LINE 707 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaGroupListT = RdKafkaGroupListT
    { groups'RdKafkaGroupListT   :: Ptr RdKafkaGroupInfoT
    , groupCnt'RdKafkaGroupListT :: Int }

instance Storable RdKafkaGroupListT where
    alignment _ = 8
{-# LINE 714 "src/Kafka/Internal/RdKafka.chs" #-}

    sizeOf _ = 16
{-# LINE 715 "src/Kafka/Internal/RdKafka.chs" #-}

    peek p = RdKafkaGroupListT
        <$> liftM castPtr       ((\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO (C2HSImp.Ptr (RdKafkaGroupInfoT))}) p)
        <*> liftM fromIntegral  ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO C2HSImp.CInt}) p)
    poke p x = do
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 0 (val :: (C2HSImp.Ptr (RdKafkaGroupInfoT)))})        p (castPtr      $ groups'RdKafkaGroupListT x)
      (\ptr val -> do {C2HSImp.pokeByteOff ptr 8 (val :: C2HSImp.CInt)})     p (fromIntegral $ groupCnt'RdKafkaGroupListT x)

type RdKafkaGroupListTPtr = C2HSImp.ForeignPtr (RdKafkaGroupListT)
{-# LINE 723 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaListGroups' :: (RdKafkaTPtr) -> (CString) -> (Int) -> IO ((RdKafkaRespErrT), (Ptr RdKafkaGroupListT))
rdKafkaListGroups' a1 a2 a4 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  (flip ($)) a2 $ \a2' -> 
  alloca $ \a3' -> 
  let {a4' = fromIntegral a4} in 
  rdKafkaListGroups''_ a1' a2' a3' a4' >>= \res ->
  let {res' = cIntToEnum res} in
  peek  a3'>>= \a3'' -> 
  return (res', a3'')

{-# LINE 727 "src/Kafka/Internal/RdKafka.chs" #-}


foreign import ccall "rdkafka.h &rd_kafka_group_list_destroy"
    rdKafkaGroupListDestroyF :: FinalizerPtr RdKafkaGroupListT

foreign import ccall "rdkafka.h rd_kafka_group_list_destroy"
    rdKafkaGroupListDestroy :: Ptr RdKafkaGroupListT -> IO ()

rdKafkaListGroups :: RdKafkaTPtr -> Maybe String -> Int -> IO (Either RdKafkaRespErrT RdKafkaGroupListTPtr)
rdKafkaListGroups k g t = case g of
    Nothing -> listGroups nullPtr
    Just strGrp -> withCAString strGrp listGroups
    where
        listGroups grp = do
            (err, res) <- rdKafkaListGroups' k grp t
            case err of
                RdKafkaRespErrNoError -> Right <$> newForeignPtr res (rdKafkaGroupListDestroy res)
                e -> return $ Left e
-------------------------------------------------------------------------------------------------

-- rd_kafka_message
foreign import ccall unsafe "rdkafka.h &rd_kafka_message_destroy"
    rdKafkaMessageDestroyF :: FinalizerPtr RdKafkaMessageT

foreign import ccall unsafe "rdkafka.h rd_kafka_message_destroy"
    rdKafkaMessageDestroy :: Ptr RdKafkaMessageT -> IO ()

rdKafkaQueryWatermarkOffsets' :: (RdKafkaTPtr) -> (String) -> (CInt32T) -> (Int) -> IO ((RdKafkaRespErrT), (Int64), (Int64))
rdKafkaQueryWatermarkOffsets' a1 a2 a3 a6 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  let {a3' = cIntConv a3} in 
  alloca $ \a4' -> 
  alloca $ \a5' -> 
  let {a6' = cIntConv a6} in 
  rdKafkaQueryWatermarkOffsets''_ a1' a2' a3' a4' a5' a6' >>= \res ->
  let {res' = cIntToEnum res} in
  peekInt64Conv  a4'>>= \a4'' -> 
  peekInt64Conv  a5'>>= \a5'' -> 
  return (res', a4'', a5'')

{-# LINE 758 "src/Kafka/Internal/RdKafka.chs" #-}



rdKafkaQueryWatermarkOffsets :: RdKafkaTPtr -> String -> Int -> Int -> IO (Either RdKafkaRespErrT (Int64, Int64))
rdKafkaQueryWatermarkOffsets kafka topic partition timeout = do
    (err, l, h) <- rdKafkaQueryWatermarkOffsets' kafka topic (cIntConv partition) timeout
    return $ case err of
                RdKafkaRespErrNoError -> Right (cIntConv l, cIntConv h)
                e                     -> Left e

type RdKafkaTimestampTypeTPtr = C2HSImp.ForeignPtr (RdKafkaTimestampTypeT)
{-# LINE 768 "src/Kafka/Internal/RdKafka.chs" #-}


instance Storable RdKafkaTimestampTypeT where
  sizeOf _    = 4
{-# LINE 771 "src/Kafka/Internal/RdKafka.chs" #-}

  alignment _ = 4
{-# LINE 772 "src/Kafka/Internal/RdKafka.chs" #-}

  peek p      = cIntToEnum <$> peek (castPtr p)
  poke p x    = poke (castPtr p) (enumToCInt x)

rdKafkaReadTimestamp' :: (Ptr RdKafkaMessageT) -> (RdKafkaTimestampTypeTPtr) -> IO ((CInt64T))
rdKafkaReadTimestamp' a1 a2 =
  let {a1' = castPtr a1} in 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaReadTimestamp''_ a1' a2' >>= \res ->
  let {res' = cIntConv res} in
  return (res')

{-# LINE 777 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaMessageTimestamp :: (RdKafkaMessageTPtr) -> (RdKafkaTimestampTypeTPtr) -> IO ((CInt64T))
rdKafkaMessageTimestamp a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaMessageTimestamp'_ a1' a2' >>= \res ->
  let {res' = cIntConv res} in
  return (res')

{-# LINE 780 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaOffsetsForTimes :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> (Int) -> IO ((RdKafkaRespErrT))
rdKafkaOffsetsForTimes a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  let {a3' = fromIntegral a3} in 
  rdKafkaOffsetsForTimes'_ a1' a2' a3' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 783 "src/Kafka/Internal/RdKafka.chs" #-}


-- rd_kafka_conf
rdKafkaConfNew :: IO ((RdKafkaConfTPtr))
rdKafkaConfNew =
  rdKafkaConfNew'_ >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 787 "src/Kafka/Internal/RdKafka.chs" #-}


foreign import ccall unsafe "rdkafka.h &rd_kafka_conf_destroy"
    rdKafkaConfDestroy :: FinalizerPtr RdKafkaConfT

rdKafkaConfDup :: (RdKafkaConfTPtr) -> IO ((RdKafkaConfTPtr))
rdKafkaConfDup a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaConfDup'_ a1' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 793 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConfSet :: (RdKafkaConfTPtr) -> (String) -> (String) -> (CCharBufPointer) -> (CSize) -> IO ((RdKafkaConfResT))
rdKafkaConfSet a1 a2 a3 a4 a5 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  C2HSImp.withCString a3 $ \a3' -> 
  let {a4' = id a4} in 
  let {a5' = cIntConv a5} in 
  rdKafkaConfSet'_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 797 "src/Kafka/Internal/RdKafka.chs" #-}


newRdKafkaConfT :: IO RdKafkaConfTPtr
newRdKafkaConfT = do
    ret <- rdKafkaConfNew
    addForeignPtrFinalizer rdKafkaConfDestroy ret
    return ret

rdKafkaConfDump :: (RdKafkaConfTPtr) -> (CSizePtr) -> IO ((Ptr CString))
rdKafkaConfDump a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = castPtr a2} in 
  rdKafkaConfDump'_ a1' a2' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 806 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConfDumpFree :: (Ptr CString) -> (CSize) -> IO ()
rdKafkaConfDumpFree a1 a2 =
  let {a1' = id a1} in 
  let {a2' = cIntConv a2} in 
  rdKafkaConfDumpFree'_ a1' a2' >>
  return ()

{-# LINE 809 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConfPropertiesShow :: (CFilePtr) -> IO ()
rdKafkaConfPropertiesShow a1 =
  let {a1' = id a1} in 
  rdKafkaConfPropertiesShow'_ a1' >>
  return ()

{-# LINE 812 "src/Kafka/Internal/RdKafka.chs" #-}


-- rd_kafka_topic_conf
rdKafkaTopicConfNew :: IO ((RdKafkaTopicConfTPtr))
rdKafkaTopicConfNew =
  rdKafkaTopicConfNew'_ >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 816 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaTopicConfDup :: (RdKafkaTopicConfTPtr) -> IO ((RdKafkaTopicConfTPtr))
rdKafkaTopicConfDup a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaTopicConfDup'_ a1' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 819 "src/Kafka/Internal/RdKafka.chs" #-}


foreign import ccall unsafe "rdkafka.h &rd_kafka_topic_conf_destroy"
    rdKafkaTopicConfDestroy :: FinalizerPtr RdKafkaTopicConfT

rdKafkaTopicConfSet :: (RdKafkaTopicConfTPtr) -> (String) -> (String) -> (CCharBufPointer) -> (CSize) -> IO ((RdKafkaConfResT))
rdKafkaTopicConfSet a1 a2 a3 a4 a5 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  C2HSImp.withCString a3 $ \a3' -> 
  let {a4' = id a4} in 
  let {a5' = cIntConv a5} in 
  rdKafkaTopicConfSet'_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 826 "src/Kafka/Internal/RdKafka.chs" #-}


newRdKafkaTopicConfT :: IO RdKafkaTopicConfTPtr
newRdKafkaTopicConfT = do
    ret <- rdKafkaTopicConfNew
    addForeignPtrFinalizer rdKafkaTopicConfDestroy ret
    return ret

rdKafkaTopicConfDump :: (RdKafkaTopicConfTPtr) -> (CSizePtr) -> IO ((Ptr CString))
rdKafkaTopicConfDump a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = castPtr a2} in 
  rdKafkaTopicConfDump'_ a1' a2' >>= \res ->
  let {res' = id res} in
  return (res')

{-# LINE 835 "src/Kafka/Internal/RdKafka.chs" #-}


-- rd_kafka
rdKafkaNew :: (RdKafkaTypeT) -> (RdKafkaConfTPtr) -> (CCharBufPointer) -> (CSize) -> IO ((RdKafkaTPtr))
rdKafkaNew a1 a2 a3 a4 =
  let {a1' = enumToCInt a1} in 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  let {a3' = id a3} in 
  let {a4' = cIntConv a4} in 
  rdKafkaNew'_ a1' a2' a3' a4' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 840 "src/Kafka/Internal/RdKafka.chs" #-}


newRdKafkaT :: RdKafkaTypeT -> RdKafkaConfTPtr -> IO (Either Text RdKafkaTPtr)
newRdKafkaT kafkaType confPtr =
    allocaBytes nErrorBytes $ \charPtr -> do
        duper <- rdKafkaConfDup confPtr
        ret <- rdKafkaNew kafkaType duper charPtr (fromIntegral nErrorBytes)
        withForeignPtr ret $ \realPtr -> do
            if realPtr == nullPtr then peekCText charPtr >>= return . Left
            else do
                -- Issue #151
                -- rd_kafka_destroy_flags may call back into Haskell if an
                -- error or log callback is set, so we must use a concurrent
                -- finalizer
                Concurrent.addForeignPtrFinalizer ret $ do
                  -- do not call 'rd_kafka_close_consumer' on destroying all Kafka.
                  -- when needed, applications should do it explicitly.
                  -- RD_KAFKA_DESTROY_F_NO_CONSUMER_CLOSE = 0x8
                  rd_kafka_destroy_flags realPtr 0x8
                return $ Right ret

rdKafkaBrokersAdd :: (RdKafkaTPtr) -> (String) -> IO ((Int))
rdKafkaBrokersAdd a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  rdKafkaBrokersAdd'_ a1' a2' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 862 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaSetLogLevel :: (RdKafkaTPtr) -> (Int) -> IO ()
rdKafkaSetLogLevel a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  rdKafkaSetLogLevel'_ a1' a2' >>
  return ()

{-# LINE 865 "src/Kafka/Internal/RdKafka.chs" #-}


-- rd_kafka consume

rdKafkaConsumeStartInternal :: (RdKafkaTopicTPtr) -> (CInt32T) -> (CInt64T) -> IO ((Int))
rdKafkaConsumeStartInternal a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = cIntConv a2} in 
  let {a3' = cIntConv a3} in 
  rdKafkaConsumeStartInternal'_ a1' a2' a3' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 870 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConsumeStart :: RdKafkaTopicTPtr -> Int -> Int64 -> IO (Maybe String)
rdKafkaConsumeStart topicPtr partition offset = do
    i <- rdKafkaConsumeStartInternal topicPtr (fromIntegral partition) (fromIntegral offset)
    case i of
        -1 -> kafkaErrnoString >>= return . Just
        _ -> return Nothing
rdKafkaConsumeStopInternal :: (RdKafkaTopicTPtr) -> (CInt32T) -> IO ((Int))
rdKafkaConsumeStopInternal :: RdKafkaTopicTPtr -> CInt -> IO Int
rdKafkaConsumeStopInternal a1 :: RdKafkaTopicTPtr
a1 a2 :: CInt
a2 =
  RdKafkaTopicTPtr -> (Ptr RdKafkaTopicT -> IO Int) -> IO Int
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
C2HSImp.withForeignPtr RdKafkaTopicTPtr
a1 ((Ptr RdKafkaTopicT -> IO Int) -> IO Int)
-> (Ptr RdKafkaTopicT -> IO Int) -> IO Int
forall a b. (a -> b) -> a -> b
$ \a1' :: Ptr RdKafkaTopicT
a1' -> 
  let {a2' :: CInt
a2' = CInt -> CInt
forall a b. (Integral a, Num b) => a -> b
cIntConv CInt
a2} in 
  Ptr RdKafkaTopicT -> CInt -> IO CInt
rdKafkaConsumeStopInternal'_ Ptr RdKafkaTopicT
a1' CInt
a2' IO CInt -> (CInt -> IO Int) -> IO Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CInt
res ->
  let {res' :: Int
res' = CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
res} in
  Int -> IO Int
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
res')

{-# LINE 879 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaSeek :: (RdKafkaTopicTPtr) -> (Int32) -> (Int64) -> (Int) -> IO ((RdKafkaRespErrT))
rdKafkaSeek a1 a2 a3 a4 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = fromIntegral a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = fromIntegral a4} in 
  rdKafkaSeek'_ a1' a2' a3' a4' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 882 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConsume :: (RdKafkaTopicTPtr) -> (CInt32T) -> (Int) -> IO ((RdKafkaMessageTPtr))
rdKafkaConsume a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = cIntConv a2} in 
  let {a3' = fromIntegral a3} in 
  rdKafkaConsume'_ a1' a2' a3' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 885 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConsumeBatch :: (RdKafkaTopicTPtr) -> (CInt32T) -> (Int) -> (Ptr (Ptr RdKafkaMessageT)) -> (CSize) -> IO ((CSize))
rdKafkaConsumeBatch a1 a2 a3 a4 a5 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = cIntConv a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = castPtr a4} in 
  let {a5' = cIntConv a5} in 
  rdKafkaConsumeBatch'_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = cIntConv res} in
  return (res')

{-# LINE 889 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaConsumeStop :: RdKafkaTopicTPtr -> Int -> IO (Maybe String)
rdKafkaConsumeStop topicPtr partition = do
    i <- rdKafkaConsumeStopInternal topicPtr (fromIntegral partition)
    case i of
        -1 -> kafkaErrnoString >>= return . Just
        _ -> return Nothing

rdKafkaOffsetStore :: (RdKafkaTopicTPtr) -> (CInt32T) -> (CInt64T) -> IO ((RdKafkaRespErrT))
rdKafkaOffsetStore :: RdKafkaTopicTPtr -> CInt -> CLLong -> IO RdKafkaRespErrT
rdKafkaOffsetStore a1 :: RdKafkaTopicTPtr
a1 a2 :: CInt
a2 a3 :: CLLong
a3 =
  RdKafkaTopicTPtr
-> (Ptr RdKafkaTopicT -> IO RdKafkaRespErrT) -> IO RdKafkaRespErrT
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
C2HSImp.withForeignPtr RdKafkaTopicTPtr
a1 ((Ptr RdKafkaTopicT -> IO RdKafkaRespErrT) -> IO RdKafkaRespErrT)
-> (Ptr RdKafkaTopicT -> IO RdKafkaRespErrT) -> IO RdKafkaRespErrT
forall a b. (a -> b) -> a -> b
$ \a1' :: Ptr RdKafkaTopicT
a1' -> 
  let {a2' :: CInt
a2' = CInt -> CInt
forall a b. (Integral a, Num b) => a -> b
cIntConv CInt
a2} in 
  let {a3' :: CLLong
a3' = CLLong -> CLLong
forall a b. (Integral a, Num b) => a -> b
cIntConv CLLong
a3} in 
  Ptr RdKafkaTopicT -> CInt -> CLLong -> IO CInt
rdKafkaOffsetStore'_ Ptr RdKafkaTopicT
a1' CInt
a2' CLLong
a3' IO CInt -> (CInt -> IO RdKafkaRespErrT) -> IO RdKafkaRespErrT
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CInt
res ->
  let {res' :: RdKafkaRespErrT
res' = CInt -> RdKafkaRespErrT
forall a. Enum a => CInt -> a
cIntToEnum CInt
res} in
  RdKafkaRespErrT -> IO RdKafkaRespErrT
forall (m :: * -> *) a. Monad m => a -> m a
return (RdKafkaRespErrT
res')

{-# LINE 900 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaOffsetsStore :: (RdKafkaTPtr) -> (RdKafkaTopicPartitionListTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaOffsetsStore a1 a2 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaOffsetsStore'_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  return (res')

{-# LINE 904 "src/Kafka/Internal/RdKafka.chs" #-}


-- rd_kafka produce

rdKafkaProduce :: (RdKafkaTopicTPtr) -> (CInt32T) -> (Int) -> (Word8Ptr) -> (CSize) -> (Word8Ptr) -> (CSize) -> (Ptr ()) -> IO ((Int))
rdKafkaProduce a1 a2 a3 a4 a5 a6 a7 a8 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = cIntConv a2} in 
  let {a3' = fromIntegral a3} in 
  let {a4' = castPtr a4} in 
  let {a5' = cIntConv a5} in 
  let {a6' = castPtr a6} in 
  let {a7' = cIntConv a7} in 
  let {a8' = castPtr a8} in 
  rdKafkaProduce'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 911 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaProduceBatch :: (RdKafkaTopicTPtr) -> (CInt32T) -> (Int) -> (RdKafkaMessageTPtr) -> (Int) -> IO ((Int))
rdKafkaProduceBatch a1 a2 a3 a4 a5 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = cIntConv a2} in 
  let {a3' = fromIntegral a3} in 
  C2HSImp.withForeignPtr a4 $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  rdKafkaProduceBatch'_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 914 "src/Kafka/Internal/RdKafka.chs" #-}



-- rd_kafka_metadata

rdKafkaMetadata' :: (RdKafkaTPtr) -> (Bool) -> (RdKafkaTopicTPtr) -> (Int) -> IO ((RdKafkaRespErrT), (Ptr RdKafkaMetadataT))
rdKafkaMetadata' a1 a2 a3 a5 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  let {a2' = boolToCInt a2} in 
  C2HSImp.withForeignPtr a3 $ \a3' -> 
  alloca $ \a4' -> 
  let {a5' = fromIntegral a5} in 
  rdKafkaMetadata''_ a1' a2' a3' a4' a5' >>= \res ->
  let {res' = cIntToEnum res} in
  peekPtr  a4'>>= \a4'' -> 
  return (res', a4'')

{-# LINE 922 "src/Kafka/Internal/RdKafka.chs" #-}


foreign import ccall unsafe "rdkafka.h rd_kafka_metadata_destroy"
    rdKafkaMetadataDestroy :: Ptr RdKafkaMetadataT -> IO ()

rdKafkaMetadata :: RdKafkaTPtr -> Bool -> Maybe RdKafkaTopicTPtr -> Int -> IO (Either RdKafkaRespErrT RdKafkaMetadataTPtr)
rdKafkaMetadata k allTopics mt timeout = do
    tptr <- maybe (newForeignPtr_ nullPtr) pure mt
    (err, res) <- rdKafkaMetadata' k allTopics tptr timeout
    case err of
        RdKafkaRespErrNoError -> Right <$> newForeignPtr :: forall a. Ptr a -> IO () -> IO (ForeignPtr a)
newForeignPtr Ptr RdKafkaMetadataT
res (Ptr RdKafkaMetadataT -> IO ()
rdKafkaMetadataDestroy Ptr RdKafkaMetadataT
res)
        e :: RdKafkaRespErrT
e -> Either RdKafkaRespErrT RdKafkaMetadataTPtr
-> IO (Either RdKafkaRespErrT RdKafkaMetadataTPtr)
forall (m :: * -> *) a. Monad m => a -> m a
return (RdKafkaRespErrT -> Either RdKafkaRespErrT RdKafkaMetadataTPtr
forall a b. a -> Either a b
Left RdKafkaRespErrT
e)

rdKafkaPoll :: (RdKafkaTPtr) -> (Int) -> IO ((Int))
rdKafkaPoll :: RdKafkaTPtr -> Int -> IO Int
rdKafkaPoll a1 :: RdKafkaTPtr
a1 a2 :: Int
a2 =
  RdKafkaTPtr -> (Ptr RdKafkaT -> IO Int) -> IO Int
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
C2HSImp.withForeignPtr RdKafkaTPtr
a1 ((Ptr RdKafkaT -> IO Int) -> IO Int)
-> (Ptr RdKafkaT -> IO Int) -> IO Int
forall a b. (a -> b) -> a -> b
$ \a1' :: Ptr RdKafkaT
a1' -> 
  let {a2' :: CInt
a2' = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in 
  Ptr RdKafkaT -> CInt -> IO CInt
rdKafkaPoll'_ Ptr RdKafkaT
a1' CInt
a2' IO CInt -> (CInt -> IO Int) -> IO Int
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CInt
res ->
  let {res' :: Int
res' = CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
res} in
  Int -> IO Int
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
res')

{-# LINE 936 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaOutqLen :: (RdKafkaTPtr) -> IO ((Int))
rdKafkaOutqLen a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaOutqLen'_ a1' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 939 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaDump :: (CFilePtr) -> (RdKafkaTPtr) -> IO ()
rdKafkaDump a1 a2 =
  let {a1' = id a1} in 
  C2HSImp.withForeignPtr a2 $ \a2' -> 
  rdKafkaDump'_ a1' a2' >>
  return ()

{-# LINE 942 "src/Kafka/Internal/RdKafka.chs" #-}


-- rd_kafka_topic
rdKafkaTopicName :: (RdKafkaTopicTPtr) -> IO ((String))
rdKafkaTopicName a1 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  rdKafkaTopicName'_ a1' >>= \res ->
  C2HSImp.peekCString res >>= \res' ->
  return (res')

{-# LINE 946 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaTopicNew :: (RdKafkaTPtr) -> (String) -> (RdKafkaTopicConfTPtr) -> IO ((RdKafkaTopicTPtr))
rdKafkaTopicNew a1 a2 a3 =
  C2HSImp.withForeignPtr a1 $ \a1' -> 
  C2HSImp.withCString a2 $ \a2' -> 
  C2HSImp.withForeignPtr a3 $ \a3' -> 
  rdKafkaTopicNew'_ a1' a2' a3' >>= \res ->
  C2HSImp.newForeignPtr_ res >>= \res' ->
  return (res')

{-# LINE 949 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaTopicDestroy :: (Ptr RdKafkaTopicT) -> IO ()
rdKafkaTopicDestroy a1 =
  let {a1' = castPtr a1} in 
  rdKafkaTopicDestroy'_ a1' >>
  return ()

{-# LINE 952 "src/Kafka/Internal/RdKafka.chs" #-}


destroyUnmanagedRdKafkaTopic :: RdKafkaTopicTPtr -> IO ()
destroyUnmanagedRdKafkaTopic ptr =
  withForeignPtr ptr rdKafkaTopicDestroy

foreign import ccall unsafe "rdkafka.h &rd_kafka_topic_destroy"
    rdKafkaTopicDestroy' :: FinalizerPtr RdKafkaTopicT

newUnmanagedRdKafkaTopicT :: RdKafkaTPtr -> String -> Maybe RdKafkaTopicConfTPtr -> IO (Either String RdKafkaTopicTPtr)
newUnmanagedRdKafkaTopicT :: RdKafkaTPtr
-> String
-> Maybe RdKafkaTopicConfTPtr
-> IO (Either String RdKafkaTopicTPtr)
newUnmanagedRdKafkaTopicT kafkaPtr :: RdKafkaTPtr
kafkaPtr topic :: String
topic topicConfPtr :: Maybe RdKafkaTopicConfTPtr
topicConfPtr = do
    RdKafkaTopicConfTPtr
duper <- IO RdKafkaTopicConfTPtr
-> (RdKafkaTopicConfTPtr -> IO RdKafkaTopicConfTPtr)
-> Maybe RdKafkaTopicConfTPtr
-> IO RdKafkaTopicConfTPtr
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Ptr RdKafkaTopicConfT -> IO RdKafkaTopicConfTPtr
forall a. Ptr a -> IO (ForeignPtr a)
newForeignPtr_ Ptr RdKafkaTopicConfT
forall b. Ptr b
nullPtr) RdKafkaTopicConfTPtr -> IO RdKafkaTopicConfTPtr
rdKafkaTopicConfDup Maybe RdKafkaTopicConfTPtr
topicConfPtr
    RdKafkaTopicTPtr
ret <- RdKafkaTPtr
-> String -> RdKafkaTopicConfTPtr -> IO RdKafkaTopicTPtr
rdKafkaTopicNew RdKafkaTPtr
kafkaPtr String
topic RdKafkaTopicConfTPtr
duper
    RdKafkaTopicTPtr
-> (Ptr RdKafkaTopicT -> IO (Either String RdKafkaTopicTPtr))
-> IO (Either String RdKafkaTopicTPtr)
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr RdKafkaTopicTPtr
ret ((Ptr RdKafkaTopicT -> IO (Either String RdKafkaTopicTPtr))
 -> IO (Either String RdKafkaTopicTPtr))
-> (Ptr RdKafkaTopicT -> IO (Either String RdKafkaTopicTPtr))
-> IO (Either String RdKafkaTopicTPtr)
forall a b. (a -> b) -> a -> b
$ \realPtr :: Ptr RdKafkaTopicT
realPtr ->
        if Ptr RdKafkaTopicT
realPtr Ptr RdKafkaTopicT -> Ptr RdKafkaTopicT -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr RdKafkaTopicT
forall b. Ptr b
nullPtr then IO String
kafkaErrnoString IO String
-> (String -> IO (Either String RdKafkaTopicTPtr))
-> IO (Either String RdKafkaTopicTPtr)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Either String RdKafkaTopicTPtr
-> IO (Either String RdKafkaTopicTPtr)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either String RdKafkaTopicTPtr
 -> IO (Either String RdKafkaTopicTPtr))
-> (String -> Either String RdKafkaTopicTPtr)
-> String
-> IO (Either String RdKafkaTopicTPtr)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Either String RdKafkaTopicTPtr
forall a b. a -> Either a b
Left
        else Either String RdKafkaTopicTPtr
-> IO (Either String RdKafkaTopicTPtr)
forall (m :: * -> *) a. Monad m => a -> m a
return (Either String RdKafkaTopicTPtr
 -> IO (Either String RdKafkaTopicTPtr))
-> Either String RdKafkaTopicTPtr
-> IO (Either String RdKafkaTopicTPtr)
forall a b. (a -> b) -> a -> b
$ RdKafkaTopicTPtr -> Either String RdKafkaTopicTPtr
forall a b. b -> Either a b
Right RdKafkaTopicTPtr
ret

newRdKafkaTopicT :: RdKafkaTPtr -> String -> Maybe RdKafkaTopicConfTPtr -> IO (Either String RdKafkaTopicTPtr)
newRdKafkaTopicT :: RdKafkaTPtr
-> String
-> Maybe RdKafkaTopicConfTPtr
-> IO (Either String RdKafkaTopicTPtr)
newRdKafkaTopicT kafkaPtr :: RdKafkaTPtr
kafkaPtr topic :: String
topic topicConfPtr :: Maybe RdKafkaTopicConfTPtr
topicConfPtr = do
    Either String RdKafkaTopicTPtr
res <- RdKafkaTPtr
-> String
-> Maybe RdKafkaTopicConfTPtr
-> IO (Either String RdKafkaTopicTPtr)
newUnmanagedRdKafkaTopicT RdKafkaTPtr
kafkaPtr String
topic Maybe RdKafkaTopicConfTPtr
topicConfPtr
    Either String ()
_ <- (RdKafkaTopicTPtr -> IO ())
-> Either String RdKafkaTopicTPtr -> IO (Either String ())
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (FinalizerPtr RdKafkaTopicT -> RdKafkaTopicTPtr -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
addForeignPtrFinalizer FinalizerPtr RdKafkaTopicT
rdKafkaTopicDestroy') Either String RdKafkaTopicTPtr
res
    Either String RdKafkaTopicTPtr
-> IO (Either String RdKafkaTopicTPtr)
forall (m :: * -> *) a. Monad m => a -> m a
return Either String RdKafkaTopicTPtr
res

-------------------------------------------------------------------------------------------------
---- Errors

data RdKafkaErrorT
type RdKafkaErrorTPtr = C2HSImp.Ptr (RdKafkaErrorT)
{-# LINE 979 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaErrorCode :: (RdKafkaErrorTPtr) -> IO ((RdKafkaRespErrT))
rdKafkaErrorCode :: RdKafkaErrorTPtr -> IO RdKafkaRespErrT
rdKafkaErrorCode a1 :: RdKafkaErrorTPtr
a1 =
  let {a1' :: RdKafkaErrorTPtr
a1' = RdKafkaErrorTPtr -> RdKafkaErrorTPtr
forall a. a -> a
id RdKafkaErrorTPtr
a1} in 
  RdKafkaErrorTPtr -> IO CInt
rdKafkaErrorCode'_ RdKafkaErrorTPtr
a1' IO CInt -> (CInt -> IO RdKafkaRespErrT) -> IO RdKafkaRespErrT
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CInt
res ->
  let {res' :: RdKafkaRespErrT
res' = CInt -> RdKafkaRespErrT
forall a. Enum a => CInt -> a
cIntToEnum CInt
res} in
  RdKafkaRespErrT -> IO RdKafkaRespErrT
forall (m :: * -> *) a. Monad m => a -> m a
return (RdKafkaRespErrT
res')

{-# LINE 982 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaErrorDestroy :: (RdKafkaErrorTPtr) -> IO ()
rdKafkaErrorDestroy a1 =
  let {a1' = id a1} in 
  rdKafkaErrorDestroy'_ a1' >>
  return ()

{-# LINE 985 "src/Kafka/Internal/RdKafka.chs" #-}

-------------------------------------------------------------------------------------------------
---- Headers

data RdKafkaHeadersT
type RdKafkaHeadersTPtr = C2HSImp.Ptr (RdKafkaHeadersT)
{-# LINE 990 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaHeaderGetAll :: (RdKafkaHeadersTPtr) -> (CSize) -> (Ptr CString) -> (Ptr Word8Ptr) -> (CSizePtr) -> IO ((RdKafkaRespErrT))
rdKafkaHeaderGetAll :: RdKafkaHeadersTPtr
-> CSize
-> Ptr CString
-> Ptr Word8Ptr
-> CSizePtr
-> IO RdKafkaRespErrT
rdKafkaHeaderGetAll a1 :: RdKafkaHeadersTPtr
a1 a2 :: CSize
a2 a3 :: Ptr CString
a3 a4 :: Ptr Word8Ptr
a4 a5 :: CSizePtr
a5 =
  let {a1' :: RdKafkaHeadersTPtr
a1' = RdKafkaHeadersTPtr -> RdKafkaHeadersTPtr
forall a. a -> a
id RdKafkaHeadersTPtr
a1} in 
  let {a2' :: CULong
a2' = CSize -> CULong
forall a b. (Integral a, Num b) => a -> b
cIntConv CSize
a2} in 
  let {a3' :: Ptr b
a3' = Ptr CString -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr Ptr CString
a3} in 
  let {a4' :: Ptr b
a4' = Ptr Word8Ptr -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr Ptr Word8Ptr
a4} in 
  let {a5' :: Ptr b
a5' = CSizePtr -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr CSizePtr
a5} in 
  RdKafkaHeadersTPtr
-> CULong -> Ptr CString -> Ptr (Ptr ()) -> Ptr CULong -> IO CInt
rdKafkaHeaderGetAll'_ RdKafkaHeadersTPtr
a1' CULong
a2' Ptr CString
forall b. Ptr b
a3' Ptr (Ptr ())
forall b. Ptr b
a4' Ptr CULong
forall b. Ptr b
a5' IO CInt -> (CInt -> IO RdKafkaRespErrT) -> IO RdKafkaRespErrT
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: CInt
res ->
  let {res' :: RdKafkaRespErrT
res' = CInt -> RdKafkaRespErrT
forall a. Enum a => CInt -> a
cIntToEnum CInt
res :: CInt
res :: CInt
res} in
  RdKafkaRespErrT -> IO RdKafkaRespErrT
forall (m :: * -> *) a. Monad m => a -> m a
return (RdKafkaRespErrT
res')

{-# LINE 993 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaMessageHeaders :: (Ptr RdKafkaMessageT) -> IO ((RdKafkaRespErrT), (RdKafkaHeadersTPtr))
rdKafkaMessageHeaders a1 =
  let {a1' = castPtr a1} in 
  alloca $ \a2' -> 
  rdKafkaMessageHeaders'_ a1' a2' >>= \res ->
  let {res' = cIntToEnum res} in
  peekPtr  a2'>>= \a2'' -> 
  return (res', a2'')

{-# LINE 996 "src/Kafka/Internal/RdKafka.chs" #-}


--- Produceva api

data RdKafkaVtypeT = RdKafkaVtypeEnd
                   | RdKafkaVtypeTopic
                   | RdKafkaVtypeRkt
                   | RdKafkaVtypePartition
                   | RdKafkaVtypeValue
                   | RdKafkaVtypeKey
                   | RdKafkaVtypeOpaque
                   | RdKafkaVtypeMsgflags
                   | RdKafkaVtypeTimestamp
                   | RdKafkaVtypeHeader
                   | RdKafkaVtypeHeaders
  deriving (Int -> RdKafkaVtypeT
RdKafkaVtypeT -> Int
RdKafkaVtypeT -> [RdKafkaVtypeT]
RdKafkaVtypeT -> RdKafkaVtypeT
RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT]
RdKafkaVtypeT -> RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT]
(RdKafkaVtypeT -> RdKafkaVtypeT)
-> (RdKafkaVtypeT -> RdKafkaVtypeT)
-> (Int -> RdKafkaVtypeT)
-> (RdKafkaVtypeT -> Int)
-> (RdKafkaVtypeT -> [RdKafkaVtypeT])
-> (RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT])
-> (RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT])
-> (RdKafkaVtypeT
    -> RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT])
-> Enum RdKafkaVtypeT
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: RdKafkaVtypeT -> RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT]
$cenumFromThenTo :: RdKafkaVtypeT -> RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT]
enumFromTo :: RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT]
$cenumFromTo :: RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT]
enumFromThen :: RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT]
$cenumFromThen :: RdKafkaVtypeT -> RdKafkaVtypeT -> [RdKafkaVtypeT]
enumFrom :: RdKafkaVtypeT -> [RdKafkaVtypeT]
$cenumFrom :: RdKafkaVtypeT -> [RdKafkaVtypeT]
fromEnum :: RdKafkaVtypeT -> Int
$cfromEnum :: RdKafkaVtypeT -> Int
toEnum :: Int -> RdKafkaVtypeT
$ctoEnum :: Int -> RdKafkaVtypeT
pred :: RdKafkaVtypeT -> RdKafkaVtypeT
$cpred :: RdKafkaVtypeT -> RdKafkaVtypeT
succ :: RdKafkaVtypeT -> RdKafkaVtypeT
$csucc :: RdKafkaVtypeT -> RdKafkaVtypeT
Enum,Int -> RdKafkaVtypeT -> ShowS
[RdKafkaVtypeT] -> ShowS
RdKafkaVtypeT -> String
(Int -> RdKafkaVtypeT -> ShowS)
-> (RdKafkaVtypeT -> String)
-> ([RdKafkaVtypeT] -> ShowS)
-> Show RdKafkaVtypeT
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RdKafkaVtypeT] -> ShowS
$cshowList :: [RdKafkaVtypeT] -> ShowS
show :: RdKafkaVtypeT -> String
$cshow :: RdKafkaVtypeT -> String
showsPrec :: Int -> RdKafkaVtypeT -> ShowS
$cshowsPrec :: Int -> RdKafkaVtypeT -> ShowS
Show,RdKafkaVtypeT -> RdKafkaVtypeT -> Bool
(RdKafkaVtypeT -> RdKafkaVtypeT -> Bool)
-> (RdKafkaVtypeT -> RdKafkaVtypeT -> Bool) -> Eq RdKafkaVtypeT
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RdKafkaVtypeT -> RdKafkaVtypeT -> Bool
$c/= :: RdKafkaVtypeT -> RdKafkaVtypeT -> Bool
== :: RdKafkaVtypeT -> RdKafkaVtypeT -> Bool
$c== :: RdKafkaVtypeT -> RdKafkaVtypeT -> Bool
Eq)

{-# LINE 1000 "src/Kafka/Internal/RdKafka.chs" #-}


data RdKafkaVuT
    = Topic'RdKafkaVu CString
    | TopicHandle'RdKafkaVu (Ptr RdKafkaTopicT)
    | Partition'RdKafkaVu CInt32T
    | Value'RdKafkaVu Word8Ptr CSize
    | Key'RdKafkaVu Word8Ptr CSize
    | MsgFlags'RdKafkaVu CInt
    | Timestamp'RdKafkaVu CInt64T
    | Opaque'RdKafkaVu (Ptr ())
    | Header'RdKafkaVu CString Word8Ptr CSize
    | Headers'RdKafkaVu (Ptr RdKafkaHeadersT) -- The message object will assume ownership of the headers (unless produceva() fails)
    | End'RdKafkaVu

type RdKafkaVuTPtr = C2HSImp.ForeignPtr (RdKafkaVuT)
{-# LINE 1015 "src/Kafka/Internal/RdKafka.chs" #-}


instance Storable RdKafkaVuT where
    alignment :: RdKafkaVuT -> Int
alignment _ = 8
{-# LINE 1018 "src/Kafka/Internal/RdKafka.chs" #-}

    sizeOf _ = 72
{-# LINE 1019 "src/Kafka/Internal/RdKafka.chs" #-}

    peek p = (\ptr -> do {C2HSImp.peekByteOff ptr 0 :: IO C2HSImp.CInt}) p >>= \a -> case cIntToEnum a of
        RdKafkaVtypeEnd -> return End'RdKafkaVu
        RdKafkaVtypeTopic ->     Topic'RdKafkaVu <$> ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
        RdKafkaVtypeMsgflags ->  MsgFlags'RdKafkaVu <$> ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO C2HSImp.CInt}) p)
        RdKafkaVtypeTimestamp -> Timestamp'RdKafkaVu <$> ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO C2HSImp.CLLong}) p)
        RdKafkaVtypePartition -> Partition'RdKafkaVu <$> ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO C2HSImp.CInt}) p)
        RdKafkaVtypeHeaders ->   Headers'RdKafkaVu <$> ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (RdKafkaHeadersTPtr)}) p)
        RdKafkaVtypeValue   -> do
            nm <- liftM castPtr ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr ())}) p)
            sz <- ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO C2HSImp.CULong}) p)
            return $ Value'RdKafkaVu nm (cIntConv sz)
        RdKafkaVtypeKey   -> do
            nm <- liftM castPtr ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr ())}) p)
            sz <- ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO C2HSImp.CULong}) p)
            return $ Key'RdKafkaVu nm (cIntConv sz)
        RdKafkaVtypeRkt   -> TopicHandle'RdKafkaVu <$> ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr (RdKafkaTopicT))}) p)
        RdKafkaVtypeOpaque -> Opaque'RdKafkaVu <$> ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr ())}) p)
        RdKafkaVtypeHeader -> do
            nm <- ((\ptr -> do {C2HSImp.peekByteOff ptr 8 :: IO (C2HSImp.Ptr C2HSImp.CChar)}) p)
            val' <- liftM castPtr ((\ptr -> do {C2HSImp.peekByteOff ptr 16 :: IO (C2HSImp.Ptr ())}) p)
            sz <- ((\ptr -> do {C2HSImp.peekByteOff ptr 24 :: IO C2HSImp.CLong}) p)
            return $ Header'RdKafkaVu nm val' (cIntConv sz)
    poke :: Ptr RdKafkaVuT -> RdKafkaVuT -> IO ()
poke p :: Ptr RdKafkaVuT
p End'RdKafkaVu =
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeEnd)
    poke p :: Ptr RdKafkaVuT
p (Topic'RdKafkaVu str :: CString
str) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeTopic)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CString
val -> do {Ptr RdKafkaVuT -> Int -> CString -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (CString
val :: (C2HSImp.Ptr C2HSImp.CChar))}) Ptr RdKafkaVuT
p CString
str
    poke p :: Ptr RdKafkaVuT
p (Timestamp'RdKafkaVu tms :: CLLong
tms) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeTimestamp)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CLLong
val -> do {Ptr RdKafkaVuT -> Int -> CLLong -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (CLLong
val :: C2HSImp.CLLong)}) Ptr RdKafkaVuT
p CLLong
tms
    poke p :: Ptr RdKafkaVuT
p (Partition'RdKafkaVu prt :: CInt
prt) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypePartition)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p CInt
prt
    poke p :: Ptr RdKafkaVuT
p (MsgFlags'RdKafkaVu flags :: CInt
flags) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeMsgflags)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p CInt
flags
    poke p :: Ptr RdKafkaVuT
p (Headers'RdKafkaVu headers :: RdKafkaHeadersTPtr
headers) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeHeaders)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: RdKafkaHeadersTPtr
val -> do {Ptr RdKafkaVuT -> Int -> RdKafkaHeadersTPtr -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (RdKafkaHeadersTPtr
val :: (RdKafkaHeadersTPtr))}) Ptr RdKafkaVuT
p RdKafkaHeadersTPtr
headers
    poke p :: Ptr RdKafkaVuT
p (TopicHandle'RdKafkaVu tphandle :: Ptr RdKafkaTopicT
tphandle) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeRkt)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: Ptr RdKafkaTopicT
val -> do {Ptr RdKafkaVuT -> Int -> Ptr RdKafkaTopicT -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (Ptr RdKafkaTopicT
val :: (C2HSImp.Ptr (RdKafkaTopicT)))}) Ptr RdKafkaVuT
p Ptr RdKafkaTopicT
tphandle
    poke p :: Ptr RdKafkaVuT
p (Value'RdKafkaVu pl :: Word8Ptr
pl sz :: CSize
sz) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeValue)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CULong
val -> do {Ptr RdKafkaVuT -> Int -> CULong -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 16 (CULong
val :: C2HSImp.CULong)}) Ptr RdKafkaVuT
p (CSize -> CULong
forall a b. (Integral a, Num b) => a -> b
cIntConv CSize
sz)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: Ptr ()
val -> do {Ptr RdKafkaVuT -> Int -> Ptr () -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (Ptr ()
val :: (C2HSImp.Ptr ()))}) Ptr RdKafkaVuT
p (Word8Ptr -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Word8Ptr
pl)
    poke p :: Ptr RdKafkaVuT
p (Key'RdKafkaVu pl :: Word8Ptr
pl sz :: CSize
sz) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeKey)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CULong
val -> do {Ptr RdKafkaVuT -> Int -> CULong -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 16 (CULong
val :: C2HSImp.CULong)}) Ptr RdKafkaVuT
p (CSize -> CULong
forall a b. (Integral a, Num b) => a -> b
cIntConv CSize
sz)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: Ptr ()
val -> do {Ptr RdKafkaVuT -> Int -> Ptr () -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (Ptr ()
val :: (C2HSImp.Ptr ()))}) Ptr RdKafkaVuT
p (Word8Ptr -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Word8Ptr
pl)
    poke p :: Ptr RdKafkaVuT
p (Opaque'RdKafkaVu ptr' :: Ptr ()
ptr') = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeOpaque)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: Ptr ()
val -> do {Ptr RdKafkaVuT -> Int -> Ptr () -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (Ptr ()
val :: (C2HSImp.Ptr ()))}) Ptr RdKafkaVuT
p Ptr ()
ptr'
    poke p :: Ptr RdKafkaVuT
p (Header'RdKafkaVu nm :: CString
nm val' :: Word8Ptr
val' sz :: CSize
sz) = do
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CInt
val -> do {Ptr RdKafkaVuT -> Int -> CInt -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 0 (CInt
val :: C2HSImp.CInt)}) Ptr RdKafkaVuT
p (RdKafkaVtypeT -> CInt
forall a. Enum a => a -> CInt
enumToCInt RdKafkaVtypeT
RdKafkaVtypeHeader)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CLong
val -> do {Ptr RdKafkaVuT -> Int -> CLong -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 24 (CLong
val :: C2HSImp.CLong)}) Ptr RdKafkaVuT
p (CSize -> CLong
forall a b. (Integral a, Num b) => a -> b
cIntConv CSize
sz)
        (\ptr :: Ptr RdKafkaVuT
ptr val :: CString
val -> do {Ptr RdKafkaVuT -> Int -> CString -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 8 (CString
val :: (C2HSImp.Ptr C2HSImp.CChar))}) Ptr RdKafkaVuT
p CString
nm
        (\ptr :: Ptr RdKafkaVuT
ptr val :: Ptr ()
val -> do {Ptr RdKafkaVuT -> Int -> Ptr () -> IO ()
forall a b. Storable a => Ptr b -> Int -> a -> IO ()
C2HSImp.pokeByteOff Ptr RdKafkaVuT
ptr 16 (Ptr ()
val :: (C2HSImp.Ptr ()))}) Ptr RdKafkaVuT
p (Word8Ptr -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Word8Ptr
val')

rdKafkaMessageProduceVa' :: (RdKafkaTPtr) -> (RdKafkaVuTPtr) -> (CLong) -> IO ((RdKafkaErrorTPtr))
rdKafkaMessageProduceVa' :: RdKafkaTPtr -> RdKafkaVuTPtr -> CLong -> IO RdKafkaErrorTPtr
rdKafkaMessageProduceVa' a1 :: RdKafkaTPtr
a1 a2 :: RdKafkaVuTPtr
a2 a3 :: CLong
a3 =
  RdKafkaTPtr
-> (Ptr RdKafkaT -> IO RdKafkaErrorTPtr) -> IO RdKafkaErrorTPtr
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
C2HSImp.withForeignPtr RdKafkaTPtr
a1 ((Ptr RdKafkaT -> IO RdKafkaErrorTPtr) -> IO RdKafkaErrorTPtr)
-> (Ptr RdKafkaT -> IO RdKafkaErrorTPtr) -> IO RdKafkaErrorTPtr
forall a b. (a -> b) -> a -> b
$ \a1' :: Ptr RdKafkaT
a1' -> 
  RdKafkaVuTPtr
-> (Ptr RdKafkaVuT -> IO RdKafkaErrorTPtr) -> IO RdKafkaErrorTPtr
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
C2HSImp.withForeignPtr RdKafkaVuTPtr
a2 ((Ptr RdKafkaVuT -> IO RdKafkaErrorTPtr) -> IO RdKafkaErrorTPtr)
-> (Ptr RdKafkaVuT -> IO RdKafkaErrorTPtr) -> IO RdKafkaErrorTPtr
forall a b. (a -> b) -> a -> b
$ \a2' :: Ptr RdKafkaVuT
a2' -> 
  let {a3' :: CULong
a3' = CLong -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral CLong
a3} in 
  Ptr RdKafkaT -> Ptr RdKafkaVuT -> CULong -> IO RdKafkaErrorTPtr
rdKafkaMessageProduceVa''_ Ptr RdKafkaT
a1' Ptr RdKafkaVuT
a2' CULong
a3' IO RdKafkaErrorTPtr
-> (RdKafkaErrorTPtr -> IO RdKafkaErrorTPtr) -> IO RdKafkaErrorTPtr
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \res :: RdKafkaErrorTPtr
res ->
  let {res' :: RdKafkaErrorTPtr
res' = id res} in
  RdKafkaErrorTPtr -> IO RdKafkaErrorTPtr
forall (m :: * -> *) a. Monad m => a -> m a
return (RdKafkaErrorTPtr
res')

{-# LINE 1080 "src/Kafka/Internal/RdKafka.chs" #-}


rdKafkaMessageProduceVa :: RdKafkaTPtr -> [RdKafkaVuT] -> IO RdKafkaErrorTPtr
rdKafkaMessageProduceVa kafkaPtr vts = withArrayLen vts $ \i arrPtr -> do
    fptr <- newForeignPtr_ arrPtr
    rdKafkaMessageProduceVa' kafkaPtr fptr (cIntConv i)

-- Marshall / Unmarshall
enumToCInt :: Enum a => a -> CInt
enumToCInt :: a -> CInt
enumToCInt = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (a -> Int) -> a -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Int
forall a. Enum a => a -> Int
fromEnum
{-# INLINE enumToCInt #-}

cIntToEnum :: Enum a => CInt -> a
cIntToEnum :: CInt -> a
cIntToEnum = Int -> a
forall a. Enum a => Int -> a
toEnum (Int -> a) -> (CInt -> Int) -> CInt -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE cIntToEnum #-}

cIntConv :: (Integral a, Num b) =>  a -> b
cIntConv :: a -> b
cIntConv = a -> b
forall a b. (Integral a, Num b) => a -> b
fromIntegral
{-# INLINE cIntConv #-}

boolToCInt :: Bool -> CInt
boolToCInt :: Bool -> CInt
boolToCInt True = Int32 -> CInt
CInt 1
boolToCInt False = Int32 -> CInt
CInt 0
{-# INLINE boolToCInt #-}

peekInt64Conv :: (Storable a, Integral a) =>  Ptr a -> IO Int64
peekInt64Conv :: Ptr a -> IO Int64
peekInt64Conv  = (a -> Int64) -> IO a -> IO Int64
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM a -> Int64
forall a b. (Integral a, Num b) => a -> b
cIntConv (IO a -> IO Int64) -> (Ptr a -> IO a) -> Ptr a -> IO Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> IO a
forall a. Storable a => Ptr a -> IO a
peek
{-# INLINE peekInt64Conv #-}

peekPtr :: Ptr a -> IO (Ptr b)
peekPtr :: Ptr a -> IO (Ptr b)
peekPtr = Ptr (Ptr b) -> IO (Ptr b)
forall a. Storable a => Ptr a -> IO a
peek (Ptr (Ptr b) -> IO (Ptr b))
-> (Ptr a -> Ptr (Ptr b)) -> Ptr a -> IO (Ptr b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> Ptr (Ptr b)
forall a b. Ptr a -> Ptr b
castPtr
{-# INLINE peekPtr #-}

-- Handle -> File descriptor

foreign import ccall "" fdopen :: Fd -> CString -> IO (Ptr CFile)

handleToCFile :: Handle -> String -> IO (CFilePtr)
handleToCFile :: Handle -> String -> IO CFilePtr
handleToCFile h :: Handle
h m :: String
m =
 do CString
iomode <- String -> IO CString
newCString String
m
    Fd
fd <- Handle -> IO Fd
handleToFd Handle
h
    Fd -> CString -> IO CFilePtr
fdopen Fd
fd CString
iomode

c_stdin :: IO CFilePtr
c_stdin :: IO CFilePtr
c_stdin = Handle -> String -> IO CFilePtr
handleToCFile Handle
stdin "r"
c_stdout :: IO CFilePtr
c_stdout :: IO CFilePtr
c_stdout = Handle -> String -> IO CFilePtr
handleToCFile Handle
stdout "w"
c_stderr :: IO CFilePtr
c_stderr :: IO CFilePtr
c_stderr = Handle -> String -> IO CFilePtr
handleToCFile Handle
stderr "w"

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_version"
  rdKafkaVersion'_ :: (IO C2HSImp.CInt)

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_version_str"
  rdKafkaVersionStr'_ :: (IO (C2HSImp.Ptr C2HSImp.CChar))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_err2str"
  rdKafkaErr2str'_ :: (C2HSImp.CInt -> (IO (C2HSImp.Ptr C2HSImp.CChar)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_err2name"
  rdKafkaErr2name'_ :: (C2HSImp.CInt -> (IO (C2HSImp.Ptr C2HSImp.CChar)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_errno2err"
  rdKafkaErrno2err'_ :: (C2HSImp.CInt -> (IO C2HSImp.CInt))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_partition_list_new"
  rdKafkaTopicPartitionListNew'_ :: (C2HSImp.CInt -> (IO (C2HSImp.Ptr (RdKafkaTopicPartitionListT))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_partition_list_add"
  rdKafkaTopicPartitionListAdd'_ :: ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr (RdKafkaTopicPartitionT))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_partition_list_add_range"
  rdKafkaTopicPartitionListAddRange'_ :: ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO ())))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_partition_list_copy"
  rdKafkaTopicPartitionListCopy'_ :: ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (IO (C2HSImp.Ptr (RdKafkaTopicPartitionListT))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_partition_list_set_offset"
  rdKafkaTopicPartitionListSetOffset'_ :: ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (C2HSImp.CLLong -> (IO C2HSImp.CInt)))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_conf_set_opaque"
  rdKafkaConfSetOpaque'_ :: ((C2HSImp.Ptr (RdKafkaConfT)) -> ((C2HSImp.Ptr ()) -> (IO ())))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_opaque"
  rdKafkaOpaque'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (IO (C2HSImp.Ptr ())))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_conf_set_default_topic_conf"
  rdKafkaConfSetDefaultTopicConf'_ :: ((C2HSImp.Ptr (RdKafkaConfT)) -> ((C2HSImp.Ptr (RdKafkaTopicConfT)) -> (IO ())))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_partition_available"
  rdKafkaTopicPartitionAvailable'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_msg_partitioner_random"
  rdKafkaMsgPartitionerRandom'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_msg_partitioner_consistent"
  rdKafkaMsgPartitionerConsistent'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_msg_partitioner_consistent_random"
  rdKafkaMsgPartitionerConsistentRandom'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_yield"
  rdKafkaYield'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (IO ()))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_pause_partitions"
  rdKafkaPausePartitions'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_resume_partitions"
  rdKafkaResumePartitions'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_queue_new"
  rdKafkaQueueNew'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (IO (C2HSImp.Ptr (RdKafkaQueueT))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_queue_destroy"
  rdKafkaQueueDestroy'_ :: ((C2HSImp.Ptr (RdKafkaQueueT)) -> (IO ()))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_consume_queue"
  rdKafkaConsumeQueue'_ :: ((C2HSImp.Ptr (RdKafkaQueueT)) -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr (RdKafkaMessageT)))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_queue_forward"
  rdKafkaQueueForward'_ :: ((C2HSImp.Ptr (RdKafkaQueueT)) -> ((C2HSImp.Ptr (RdKafkaQueueT)) -> (IO ())))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_queue_get_partition"
  rdKafkaQueueGetPartition''_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr (RdKafkaQueueT))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_consume_batch_queue"
  rdKafkaConsumeBatchQueue''_ :: ((C2HSImp.Ptr (RdKafkaQueueT)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (RdKafkaMessageT))) -> (C2HSImp.CULong -> (IO C2HSImp.CLong)))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_subscribe"
  rdKafkaSubscribe'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_unsubscribe"
  rdKafkaUnsubscribe'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (IO C2HSImp.CInt))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_subscription"
  rdKafkaSubscription''_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (C2HSImp.Ptr (RdKafkaTopicPartitionListT))) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_consumer_poll"
  rdKafkaConsumerPoll'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr (RdKafkaMessageT)))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_consumer_close"
  rdKafkaConsumerClose'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (IO C2HSImp.CInt))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_poll_set_consumer"
  rdKafkaPollSetConsumer'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (IO C2HSImp.CInt))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_assign"
  rdKafkaAssign'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_assignment"
  rdKafkaAssignment''_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (C2HSImp.Ptr (RdKafkaTopicPartitionListT))) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_commit"
  rdKafkaCommit'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_commit_message"
  rdKafkaCommitMessage'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaMessageT)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_committed"
  rdKafkaCommitted'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_position"
  rdKafkaPosition'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_list_groups"
  rdKafkaListGroups''_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (C2HSImp.Ptr (RdKafkaGroupListT))) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_query_watermark_offsets"
  rdKafkaQueryWatermarkOffsets''_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CInt -> ((C2HSImp.Ptr C2HSImp.CLLong) -> ((C2HSImp.Ptr C2HSImp.CLLong) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_message_timestamp"
  rdKafkaReadTimestamp''_ :: ((C2HSImp.Ptr (RdKafkaMessageT)) -> ((C2HSImp.Ptr (RdKafkaTimestampTypeT)) -> (IO C2HSImp.CLLong)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_message_timestamp"
  rdKafkaMessageTimestamp'_ :: ((C2HSImp.Ptr (RdKafkaMessageT)) -> ((C2HSImp.Ptr (RdKafkaTimestampTypeT)) -> (IO C2HSImp.CLLong)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_offsets_for_times"
  rdKafkaOffsetsForTimes'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_conf_new"
  rdKafkaConfNew'_ :: (IO (C2HSImp.Ptr (RdKafkaConfT)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_conf_dup"
  rdKafkaConfDup'_ :: ((C2HSImp.Ptr (RdKafkaConfT)) -> (IO (C2HSImp.Ptr (RdKafkaConfT))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_conf_set"
  rdKafkaConfSet'_ :: ((C2HSImp.Ptr (RdKafkaConfT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_conf_dump"
  rdKafkaConfDump'_ :: ((C2HSImp.Ptr (RdKafkaConfT)) -> ((C2HSImp.Ptr C2HSImp.CULong) -> (IO (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_conf_dump_free"
  rdKafkaConfDumpFree'_ :: ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (C2HSImp.CULong -> (IO ())))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_conf_properties_show"
  rdKafkaConfPropertiesShow'_ :: ((CFilePtr) -> (IO ()))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_conf_new"
  rdKafkaTopicConfNew'_ :: (IO (C2HSImp.Ptr (RdKafkaTopicConfT)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_conf_dup"
  rdKafkaTopicConfDup'_ :: ((C2HSImp.Ptr (RdKafkaTopicConfT)) -> (IO (C2HSImp.Ptr (RdKafkaTopicConfT))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_conf_set"
  rdKafkaTopicConfSet'_ :: ((C2HSImp.Ptr (RdKafkaTopicConfT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_conf_dump"
  rdKafkaTopicConfDump'_ :: ((C2HSImp.Ptr (RdKafkaTopicConfT)) -> ((C2HSImp.Ptr C2HSImp.CULong) -> (IO (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_new"
  rdKafkaNew'_ :: (C2HSImp.CInt -> ((C2HSImp.Ptr (RdKafkaConfT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (C2HSImp.CULong -> (IO (C2HSImp.Ptr (RdKafkaT)))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_destroy_flags"
  rd_kafka_destroy_flags :: ((C2HSImp.Ptr (RdKafkaT)) -> (C2HSImp.CInt -> (IO ())))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_brokers_add"
  rdKafkaBrokersAdd'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_set_log_level"
  rdKafkaSetLogLevel'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (C2HSImp.CInt -> (IO ())))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_consume_start"
  rdKafkaConsumeStartInternal'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (C2HSImp.CLLong -> (IO C2HSImp.CInt))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_consume_stop"
  rdKafkaConsumeStopInternal'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_seek"
  rdKafkaSeek'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (C2HSImp.CLLong -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_consume"
  rdKafkaConsume'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO (C2HSImp.Ptr (RdKafkaMessageT))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_consume_batch"
  rdKafkaConsumeBatch'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (RdKafkaMessageT))) -> (C2HSImp.CULong -> (IO C2HSImp.CLong))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_offset_store"
  rdKafkaOffsetStore'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (C2HSImp.CLLong -> (IO C2HSImp.CInt))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_offsets_store"
  rdKafkaOffsetsStore'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaTopicPartitionListT)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_produce"
  rdKafkaProduce'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_produce_batch"
  rdKafkaProduceBatch'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (RdKafkaMessageT)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_metadata"
  rdKafkaMetadata''_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (RdKafkaTopicT)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (C2HSImp.CInt -> (IO C2HSImp.CInt))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_poll"
  rdKafkaPoll'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_outq_len"
  rdKafkaOutqLen'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> (IO C2HSImp.CInt))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_dump"
  rdKafkaDump'_ :: ((CFilePtr) -> ((C2HSImp.Ptr (RdKafkaT)) -> (IO ())))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_name"
  rdKafkaTopicName'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (IO (C2HSImp.Ptr C2HSImp.CChar)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_new"
  rdKafkaTopicNew'_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr C2HSImp.CChar) -> ((C2HSImp.Ptr (RdKafkaTopicConfT)) -> (IO (C2HSImp.Ptr (RdKafkaTopicT))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_topic_destroy"
  rdKafkaTopicDestroy'_ :: ((C2HSImp.Ptr (RdKafkaTopicT)) -> (IO ()))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_error_code"
  rdKafkaErrorCode'_ :: ((RdKafkaErrorTPtr) -> (IO C2HSImp.CInt))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_error_destroy"
  rdKafkaErrorDestroy'_ :: ((RdKafkaErrorTPtr) -> (IO ()))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_header_get_all"
  rdKafkaHeaderGetAll'_ :: ((RdKafkaHeadersTPtr) -> (C2HSImp.CULong -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> ((C2HSImp.Ptr C2HSImp.CULong) -> (IO C2HSImp.CInt))))))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_message_headers"
  rdKafkaMessageHeaders'_ :: ((C2HSImp.Ptr (RdKafkaMessageT)) -> ((C2HSImp.Ptr (RdKafkaHeadersTPtr)) -> (IO C2HSImp.CInt)))

foreign import ccall safe "Kafka/Internal/RdKafka.chs.h rd_kafka_produceva"
  rdKafkaMessageProduceVa''_ :: ((C2HSImp.Ptr (RdKafkaT)) -> ((C2HSImp.Ptr (RdKafkaVuT)) -> (C2HSImp.CULong -> (IO (RdKafkaErrorTPtr)))))