pub use super::*;

#[rustfmt::skip]
impl From<u32> for CreateAccountResult {
    fn from(other: u32) -> CreateAccountResult {
        use tbc::*;
        use CreateAccountResult::*;

        match other {
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_OK => Ok,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_LINKED_EVENT_FAILED => LinkedEventFailed,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_LINKED_EVENT_CHAIN_OPEN => LinkedEventChainOpen,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_EXPECTED => ImportedEventExpected,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_NOT_EXPECTED => ImportedEventNotExpected,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_TIMESTAMP_MUST_BE_ZERO => TimestampMustBeZero,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_TIMESTAMP_OUT_OF_RANGE => ImportedEventTimestampOutOfRange,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_TIMESTAMP_MUST_NOT_ADVANCE => ImportedEventTimestampMustNotAdvance,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_RESERVED_FIELD => ReservedField,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_RESERVED_FLAG => ReservedFlag,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_ID_MUST_NOT_BE_ZERO => IdMustNotBeZero,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_ID_MUST_NOT_BE_INT_MAX => IdMustNotBeIntMax,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_FLAGS => ExistsWithDifferentFlags,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_USER_DATA_128 => ExistsWithDifferentUserData128,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_USER_DATA_64 => ExistsWithDifferentUserData64,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_USER_DATA_32 => ExistsWithDifferentUserData32,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_LEDGER => ExistsWithDifferentLedger,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_CODE => ExistsWithDifferentCode,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS => Exists,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_FLAGS_ARE_MUTUALLY_EXCLUSIVE => FlagsAreMutuallyExclusive,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_DEBITS_PENDING_MUST_BE_ZERO => DebitsPendingMustBeZero,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_DEBITS_POSTED_MUST_BE_ZERO => DebitsPostedMustBeZero,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_CREDITS_PENDING_MUST_BE_ZERO => CreditsPendingMustBeZero,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_CREDITS_POSTED_MUST_BE_ZERO => CreditsPostedMustBeZero,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_LEDGER_MUST_NOT_BE_ZERO => LedgerMustNotBeZero,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_CODE_MUST_NOT_BE_ZERO => CodeMustNotBeZero,
            TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_TIMESTAMP_MUST_NOT_REGRESS => ImportedEventTimestampMustNotRegress,
            v => panic!("Unknown CreateAccountResult: {v}"),
        }
    }
}

#[rustfmt::skip]
impl From<CreateAccountResult> for u32 {
    fn from(other: CreateAccountResult) -> u32 {
        use tbc::*;
        use CreateAccountResult::*;

        match other {
            Ok => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_OK,
            LinkedEventFailed => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_LINKED_EVENT_FAILED,
            LinkedEventChainOpen => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_LINKED_EVENT_CHAIN_OPEN,
            ImportedEventExpected => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_EXPECTED,
            ImportedEventNotExpected => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_NOT_EXPECTED,
            TimestampMustBeZero => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_TIMESTAMP_MUST_BE_ZERO,
            ImportedEventTimestampOutOfRange => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_TIMESTAMP_OUT_OF_RANGE,
            ImportedEventTimestampMustNotAdvance => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_TIMESTAMP_MUST_NOT_ADVANCE,
            ReservedField => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_RESERVED_FIELD,
            ReservedFlag => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_RESERVED_FLAG,
            IdMustNotBeZero => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_ID_MUST_NOT_BE_ZERO,
            IdMustNotBeIntMax => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_ID_MUST_NOT_BE_INT_MAX,
            ExistsWithDifferentFlags => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_FLAGS,
            ExistsWithDifferentUserData128 => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_USER_DATA_128,
            ExistsWithDifferentUserData64 => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_USER_DATA_64,
            ExistsWithDifferentUserData32 => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_USER_DATA_32,
            ExistsWithDifferentLedger => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_LEDGER,
            ExistsWithDifferentCode => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS_WITH_DIFFERENT_CODE,
            Exists => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_EXISTS,
            FlagsAreMutuallyExclusive => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_FLAGS_ARE_MUTUALLY_EXCLUSIVE,
            DebitsPendingMustBeZero => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_DEBITS_PENDING_MUST_BE_ZERO,
            DebitsPostedMustBeZero => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_DEBITS_POSTED_MUST_BE_ZERO,
            CreditsPendingMustBeZero => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_CREDITS_PENDING_MUST_BE_ZERO,
            CreditsPostedMustBeZero => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_CREDITS_POSTED_MUST_BE_ZERO,
            LedgerMustNotBeZero => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_LEDGER_MUST_NOT_BE_ZERO,
            CodeMustNotBeZero => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_CODE_MUST_NOT_BE_ZERO,
            ImportedEventTimestampMustNotRegress => TB_CREATE_ACCOUNT_RESULT_TB_CREATE_ACCOUNT_IMPORTED_EVENT_TIMESTAMP_MUST_NOT_REGRESS,
        }
    }
}

#[rustfmt::skip]
impl From<u32> for CreateTransferResult {
    fn from(other: u32) -> CreateTransferResult {
        use tbc::*;
        use CreateTransferResult::*;

        match other {
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OK => Ok,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_LINKED_EVENT_FAILED => LinkedEventFailed,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_LINKED_EVENT_CHAIN_OPEN => LinkedEventChainOpen,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_EXPECTED => ImportedEventExpected,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_NOT_EXPECTED => ImportedEventNotExpected,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_TIMESTAMP_MUST_BE_ZERO => TimestampMustBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_OUT_OF_RANGE => ImportedEventTimestampOutOfRange,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_MUST_NOT_ADVANCE => ImportedEventTimestampMustNotAdvance,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_RESERVED_FLAG => ReservedFlag,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ID_MUST_NOT_BE_ZERO => IdMustNotBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ID_MUST_NOT_BE_INT_MAX => IdMustNotBeIntMax,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_FLAGS => ExistsWithDifferentFlags,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_PENDING_ID => ExistsWithDifferentPendingId,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_TIMEOUT => ExistsWithDifferentTimeout,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_DEBIT_ACCOUNT_ID => ExistsWithDifferentDebitAccountId,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_CREDIT_ACCOUNT_ID => ExistsWithDifferentCreditAccountId,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_AMOUNT => ExistsWithDifferentAmount,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_USER_DATA_128 => ExistsWithDifferentUserData128,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_USER_DATA_64 => ExistsWithDifferentUserData64,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_USER_DATA_32 => ExistsWithDifferentUserData32,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_LEDGER => ExistsWithDifferentLedger,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_CODE => ExistsWithDifferentCode,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS => Exists,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ID_ALREADY_FAILED => IdAlreadyFailed,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_FLAGS_ARE_MUTUALLY_EXCLUSIVE => FlagsAreMutuallyExclusive,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_DEBIT_ACCOUNT_ID_MUST_NOT_BE_ZERO => DebitAccountIdMustNotBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_DEBIT_ACCOUNT_ID_MUST_NOT_BE_INT_MAX => DebitAccountIdMustNotBeIntMax,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CREDIT_ACCOUNT_ID_MUST_NOT_BE_ZERO => CreditAccountIdMustNotBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CREDIT_ACCOUNT_ID_MUST_NOT_BE_INT_MAX => CreditAccountIdMustNotBeIntMax,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ACCOUNTS_MUST_BE_DIFFERENT => AccountsMustBeDifferent,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_ID_MUST_BE_ZERO => PendingIdMustBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_ID_MUST_NOT_BE_ZERO => PendingIdMustNotBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_ID_MUST_NOT_BE_INT_MAX => PendingIdMustNotBeIntMax,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_ID_MUST_BE_DIFFERENT => PendingIdMustBeDifferent,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_TIMEOUT_RESERVED_FOR_PENDING_TRANSFER => TimeoutReservedForPendingTransfer,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CLOSING_TRANSFER_MUST_BE_PENDING => ClosingTransferMustBePending,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_LEDGER_MUST_NOT_BE_ZERO => LedgerMustNotBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CODE_MUST_NOT_BE_ZERO => CodeMustNotBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_DEBIT_ACCOUNT_NOT_FOUND => DebitAccountNotFound,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CREDIT_ACCOUNT_NOT_FOUND => CreditAccountNotFound,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ACCOUNTS_MUST_HAVE_THE_SAME_LEDGER => AccountsMustHaveTheSameLedger,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_TRANSFER_MUST_HAVE_THE_SAME_LEDGER_AS_ACCOUNTS => TransferMustHaveTheSameLedgerAsAccounts,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_NOT_FOUND => PendingTransferNotFound,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_NOT_PENDING => PendingTransferNotPending,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_DEBIT_ACCOUNT_ID => PendingTransferHasDifferentDebitAccountId,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_CREDIT_ACCOUNT_ID => PendingTransferHasDifferentCreditAccountId,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_LEDGER => PendingTransferHasDifferentLedger,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_CODE => PendingTransferHasDifferentCode,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXCEEDS_PENDING_TRANSFER_AMOUNT => ExceedsPendingTransferAmount,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_AMOUNT => PendingTransferHasDifferentAmount,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_ALREADY_POSTED => PendingTransferAlreadyPosted,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_ALREADY_VOIDED => PendingTransferAlreadyVoided,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_EXPIRED => PendingTransferExpired,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_MUST_NOT_REGRESS => ImportedEventTimestampMustNotRegress,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_MUST_POSTDATE_DEBIT_ACCOUNT => ImportedEventTimestampMustPostdateDebitAccount,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_MUST_POSTDATE_CREDIT_ACCOUNT => ImportedEventTimestampMustPostdateCreditAccount,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMEOUT_MUST_BE_ZERO => ImportedEventTimeoutMustBeZero,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_DEBIT_ACCOUNT_ALREADY_CLOSED => DebitAccountAlreadyClosed,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CREDIT_ACCOUNT_ALREADY_CLOSED => CreditAccountAlreadyClosed,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_DEBITS_PENDING => OverflowsDebitsPending,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_CREDITS_PENDING => OverflowsCreditsPending,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_DEBITS_POSTED => OverflowsDebitsPosted,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_CREDITS_POSTED => OverflowsCreditsPosted,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_DEBITS => OverflowsDebits,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_CREDITS => OverflowsCredits,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_TIMEOUT => OverflowsTimeout,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXCEEDS_CREDITS => ExceedsCredits,
            TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXCEEDS_DEBITS => ExceedsDebits,
            v => panic!("Unknown CreateTransferResult: {v}"),
        }
    }
}

#[rustfmt::skip]
impl From<CreateTransferResult> for u32 {
    fn from(other: CreateTransferResult) -> u32 {
        use tbc::*;
        use CreateTransferResult::*;

        match other {
            Ok => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OK,
            LinkedEventFailed => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_LINKED_EVENT_FAILED,
            LinkedEventChainOpen => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_LINKED_EVENT_CHAIN_OPEN,
            ImportedEventExpected => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_EXPECTED,
            ImportedEventNotExpected => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_NOT_EXPECTED,
            TimestampMustBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_TIMESTAMP_MUST_BE_ZERO,
            ImportedEventTimestampOutOfRange => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_OUT_OF_RANGE,
            ImportedEventTimestampMustNotAdvance => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_MUST_NOT_ADVANCE,
            ReservedFlag => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_RESERVED_FLAG,
            IdMustNotBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ID_MUST_NOT_BE_ZERO,
            IdMustNotBeIntMax => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ID_MUST_NOT_BE_INT_MAX,
            ExistsWithDifferentFlags => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_FLAGS,
            ExistsWithDifferentPendingId => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_PENDING_ID,
            ExistsWithDifferentTimeout => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_TIMEOUT,
            ExistsWithDifferentDebitAccountId => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_DEBIT_ACCOUNT_ID,
            ExistsWithDifferentCreditAccountId => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_CREDIT_ACCOUNT_ID,
            ExistsWithDifferentAmount => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_AMOUNT,
            ExistsWithDifferentUserData128 => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_USER_DATA_128,
            ExistsWithDifferentUserData64 => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_USER_DATA_64,
            ExistsWithDifferentUserData32 => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_USER_DATA_32,
            ExistsWithDifferentLedger => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_LEDGER,
            ExistsWithDifferentCode => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS_WITH_DIFFERENT_CODE,
            Exists => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXISTS,
            IdAlreadyFailed => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ID_ALREADY_FAILED,
            FlagsAreMutuallyExclusive => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_FLAGS_ARE_MUTUALLY_EXCLUSIVE,
            DebitAccountIdMustNotBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_DEBIT_ACCOUNT_ID_MUST_NOT_BE_ZERO,
            DebitAccountIdMustNotBeIntMax => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_DEBIT_ACCOUNT_ID_MUST_NOT_BE_INT_MAX,
            CreditAccountIdMustNotBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CREDIT_ACCOUNT_ID_MUST_NOT_BE_ZERO,
            CreditAccountIdMustNotBeIntMax => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CREDIT_ACCOUNT_ID_MUST_NOT_BE_INT_MAX,
            AccountsMustBeDifferent => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ACCOUNTS_MUST_BE_DIFFERENT,
            PendingIdMustBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_ID_MUST_BE_ZERO,
            PendingIdMustNotBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_ID_MUST_NOT_BE_ZERO,
            PendingIdMustNotBeIntMax => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_ID_MUST_NOT_BE_INT_MAX,
            PendingIdMustBeDifferent => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_ID_MUST_BE_DIFFERENT,
            TimeoutReservedForPendingTransfer => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_TIMEOUT_RESERVED_FOR_PENDING_TRANSFER,
            ClosingTransferMustBePending => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CLOSING_TRANSFER_MUST_BE_PENDING,
            LedgerMustNotBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_LEDGER_MUST_NOT_BE_ZERO,
            CodeMustNotBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CODE_MUST_NOT_BE_ZERO,
            DebitAccountNotFound => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_DEBIT_ACCOUNT_NOT_FOUND,
            CreditAccountNotFound => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CREDIT_ACCOUNT_NOT_FOUND,
            AccountsMustHaveTheSameLedger => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_ACCOUNTS_MUST_HAVE_THE_SAME_LEDGER,
            TransferMustHaveTheSameLedgerAsAccounts => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_TRANSFER_MUST_HAVE_THE_SAME_LEDGER_AS_ACCOUNTS,
            PendingTransferNotFound => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_NOT_FOUND,
            PendingTransferNotPending => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_NOT_PENDING,
            PendingTransferHasDifferentDebitAccountId => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_DEBIT_ACCOUNT_ID,
            PendingTransferHasDifferentCreditAccountId => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_CREDIT_ACCOUNT_ID,
            PendingTransferHasDifferentLedger => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_LEDGER,
            PendingTransferHasDifferentCode => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_CODE,
            ExceedsPendingTransferAmount => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXCEEDS_PENDING_TRANSFER_AMOUNT,
            PendingTransferHasDifferentAmount => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_HAS_DIFFERENT_AMOUNT,
            PendingTransferAlreadyPosted => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_ALREADY_POSTED,
            PendingTransferAlreadyVoided => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_ALREADY_VOIDED,
            PendingTransferExpired => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_PENDING_TRANSFER_EXPIRED,
            ImportedEventTimestampMustNotRegress => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_MUST_NOT_REGRESS,
            ImportedEventTimestampMustPostdateDebitAccount => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_MUST_POSTDATE_DEBIT_ACCOUNT,
            ImportedEventTimestampMustPostdateCreditAccount => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMESTAMP_MUST_POSTDATE_CREDIT_ACCOUNT,
            ImportedEventTimeoutMustBeZero => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_IMPORTED_EVENT_TIMEOUT_MUST_BE_ZERO,
            DebitAccountAlreadyClosed => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_DEBIT_ACCOUNT_ALREADY_CLOSED,
            CreditAccountAlreadyClosed => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_CREDIT_ACCOUNT_ALREADY_CLOSED,
            OverflowsDebitsPending => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_DEBITS_PENDING,
            OverflowsCreditsPending => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_CREDITS_PENDING,
            OverflowsDebitsPosted => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_DEBITS_POSTED,
            OverflowsCreditsPosted => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_CREDITS_POSTED,
            OverflowsDebits => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_DEBITS,
            OverflowsCredits => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_CREDITS,
            OverflowsTimeout => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_OVERFLOWS_TIMEOUT,
            ExceedsCredits => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXCEEDS_CREDITS,
            ExceedsDebits => TB_CREATE_TRANSFER_RESULT_TB_CREATE_TRANSFER_EXCEEDS_DEBITS,
        }
    }
}

impl From<i32> for InitStatus {
    fn from(other: i32) -> InitStatus {
        use tbc::*;
        use InitStatus::*;

        match other {
            TB_INIT_STATUS_TB_INIT_SUCCESS => panic!(),
            TB_INIT_STATUS_TB_INIT_UNEXPECTED => Unexpected,
            TB_INIT_STATUS_TB_INIT_OUT_OF_MEMORY => OutOfMemory,
            TB_INIT_STATUS_TB_INIT_ADDRESS_INVALID => AddressInvalid,
            TB_INIT_STATUS_TB_INIT_ADDRESS_LIMIT_EXCEEDED => AddressLimitExceeded,
            TB_INIT_STATUS_TB_INIT_SYSTEM_RESOURCES => SystemResources,
            TB_INIT_STATUS_TB_INIT_NETWORK_SUBSYSTEM => NetworkSubsystem,
            v => panic!("Unknown InitStatus: {v}"),
        }
    }
}

impl From<InitStatus> for i32 {
    fn from(other: InitStatus) -> i32 {
        use tbc::*;
        use InitStatus::*;

        match other {
            Unexpected => TB_INIT_STATUS_TB_INIT_UNEXPECTED,
            OutOfMemory => TB_INIT_STATUS_TB_INIT_OUT_OF_MEMORY,
            AddressInvalid => TB_INIT_STATUS_TB_INIT_ADDRESS_INVALID,
            AddressLimitExceeded => TB_INIT_STATUS_TB_INIT_ADDRESS_LIMIT_EXCEEDED,
            SystemResources => TB_INIT_STATUS_TB_INIT_SYSTEM_RESOURCES,
            NetworkSubsystem => TB_INIT_STATUS_TB_INIT_NETWORK_SUBSYSTEM,
        }
    }
}

impl From<u8> for PacketStatus {
    fn from(other: u8) -> PacketStatus {
        use tbc::*;
        use PacketStatus::*;

        match other {
            TB_PACKET_STATUS_TB_PACKET_OK => panic!(),
            TB_PACKET_STATUS_TB_PACKET_TOO_MUCH_DATA => TooMuchData,
            TB_PACKET_STATUS_TB_PACKET_CLIENT_EVICTED => ClientEvicted,
            TB_PACKET_STATUS_TB_PACKET_CLIENT_RELEASE_TOO_LOW => ClientReleaseTooLow,
            TB_PACKET_STATUS_TB_PACKET_CLIENT_RELEASE_TOO_HIGH => ClientReleaseTooHigh,
            TB_PACKET_STATUS_TB_PACKET_CLIENT_SHUTDOWN => ClientShutdown,
            TB_PACKET_STATUS_TB_PACKET_INVALID_OPERATION => InvalidOperation,
            TB_PACKET_STATUS_TB_PACKET_INVALID_DATA_SIZE => InvalidDataSize,
            v => panic!("Unknown PacketStatus: {v}"),
        }
    }
}

impl From<PacketStatus> for u8 {
    fn from(other: PacketStatus) -> u8 {
        use tbc::*;
        use PacketStatus::*;

        match other {
            TooMuchData => TB_PACKET_STATUS_TB_PACKET_TOO_MUCH_DATA,
            ClientEvicted => TB_PACKET_STATUS_TB_PACKET_CLIENT_EVICTED,
            ClientReleaseTooLow => TB_PACKET_STATUS_TB_PACKET_CLIENT_RELEASE_TOO_LOW,
            ClientReleaseTooHigh => TB_PACKET_STATUS_TB_PACKET_CLIENT_RELEASE_TOO_HIGH,
            ClientShutdown => TB_PACKET_STATUS_TB_PACKET_CLIENT_SHUTDOWN,
            InvalidOperation => TB_PACKET_STATUS_TB_PACKET_INVALID_OPERATION,
            InvalidDataSize => TB_PACKET_STATUS_TB_PACKET_INVALID_DATA_SIZE,
        }
    }
}
