# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: xcapi/xray/common/serial/typed_message.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
from typing import Optional, Any
from xcapi.model import ClassMeta
from dataclasses import dataclass


@dataclass
class TypedMessage(ClassMeta):
    """TypedMessage is a serialized proto message along with its type name."""
    type: Optional[str] = None
    """The name of the message type, retrieved from protobuf API."""
    value: Optional[bytes] = None
    """Serialized proto message."""


def ToTypedMessage(message: Any) -> 'TypedMessage':
    return TypedMessage(
        type=message.DESCRIPTOR.full_name, value=message.SerializeToString()
    )


def GetMessageType(message: Any) -> str:
    return message.DESCRIPTOR.full_name


_sym_db = _symbol_database.Default()

DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
    b'\n,xcapi/xray/common/serial/typed_message.proto\x12\x12xray.common.serial\"+\n\x0cTypedMessage\x12\x0c\n\x04type\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\x62\x06proto3')

_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'xcapi.xray.common.serial.typed_message_pb', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
    DESCRIPTOR._loaded_options = None
    _globals['_TYPEDMESSAGE']._serialized_start = 68
    _globals['_TYPEDMESSAGE']._serialized_end = 111
