#
# Autogenerated by Thrift
#
# DO NOT EDIT
#  @generated
#

from __future__ import annotations

from abc import ABCMeta
import typing as _typing

import folly.iobuf as _fbthrift_iobuf

import apache.thrift.metadata.thrift_types as _fbthrift_metadata
from thrift.python.serializer import serialize_iobuf, deserialize, Protocol
from thrift.python.server import ServiceInterface, RpcKind, PythonUserException

import s.thrift_types
import s.thrift_metadata
import b.thrift_types
import c.thrift_types

class TestServiceInterface(
    ServiceInterface,
    metaclass=ABCMeta
):

    @staticmethod
    def service_name() -> bytes:
        return b"TestService"

    def getFunctionTable(self) -> _typing.Mapping[bytes, _typing.Callable[..., object]]:
        functionTable = {
            b"test": (RpcKind.SINGLE_REQUEST_SINGLE_RESPONSE, self._fbthrift__handler_test),
        }
        return {**super().getFunctionTable(), **functionTable}

    @staticmethod
    def __get_thrift_name__() -> str:
        return "s.TestService"

    @staticmethod
    def __get_metadata__() -> _fbthrift_metadata.ThriftMetadata:
        return s.thrift_metadata.gen_metadata_service_TestService()

    @staticmethod
    def __get_metadata_service_response__() -> _fbthrift_metadata.ThriftServiceMetadataResponse:
        return s.thrift_metadata._fbthrift_metadata_service_response_TestService()



    async def test(
            self
        ) -> None:
        raise NotImplementedError("async def test is not implemented")

    async def _fbthrift__handler_test(self, args: _fbthrift_iobuf.IOBuf, protocol: Protocol) -> _fbthrift_iobuf.IOBuf:
        args_struct = deserialize(s.thrift_types._fbthrift_TestService_test_args, args, protocol)
        try:
            value = await self.test()
            return_struct = s.thrift_types._fbthrift_TestService_test_result()
        except c.thrift_types.E as e:
            return_struct = s.thrift_types._fbthrift_TestService_test_result(ex=e)
            buf = serialize_iobuf(return_struct, protocol)
            exp = PythonUserException('E', str(e), buf)
            raise exp
        return serialize_iobuf(return_struct, protocol)

