K i%dZddlZddlmZmZmZddlmZddlmZddl m Z edd Z dd e d e d e fd Zdee de d e fdZd e dej d dfdZdee dej d e fdZd e d efdZd e d dfdZd e ded dfdZy)z,Contains the Nextgen Pythonic protobuf APIs.N)TextTypeTypeVar)decoder)encoder)Message_MESSAGEr)boundmessage deterministicreturnc&|j|S)aReturn the serialized proto. Args: message: The proto message to be serialized. deterministic: If true, requests deterministic serialization of the protobuf, with predictable ordering of map keys. Returns: A binary bytes representation of the message. )r )SerializeToString)r r s [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/google/protobuf/proto.py serializers  " " " ?? message_classpayloadc6|}|j||S)zGiven a serialized data in binary form, deserialize it into a Message. Args: message_class: The message meta class. payload: A serialized bytes in binary form. Returns: A new message deserialized from payload. )ParseFromString)rr new_messages rparser"s+ g& routputc|j}tj|j||jt |}||k7rt d||fzy)aWrites the size of the message as a varint and the serialized message. Writes the size of the message as a varint and then the serialized message. This allows more data to be written to the output after the message. Use parse_length_prefixed to parse messages written by this method. The output stream must be buffered, e.g. using https://docs.python.org/3/library/io.html#buffered-streams. Example usage: out = io.BytesIO() for msg in message_list: proto.serialize_length_prefixed(msg, out) Args: message: The protocol buffer message that should be serialized. output: BytesIO or custom buffered IO that data should be written to. z_Failed to write complete message (wrote: %d, expected: %d). Ensure output is using buffered IO.N)ByteSizer_VarintEncoderwriter TypeError)r rsizeout_sizes rserialize_length_prefixedr!1sk&    $'6<<. \\)G, -(   03;T2B C r input_bytesctj|}|y|}|dk(r|S|j|j|}||k7r0t dj |||j j|S)aParse a message from input_bytes. Args: message_class: The protocol buffer message class that parser should parse. input_bytes: A buffered input. Example usage: while True: msg = proto.parse_length_prefixed(message_class, input_bytes) if msg is None: break ... Returns: A parsed message if successful. None if input_bytes is at EOF. NrzdTruncated message or non-buffered input_bytes: Expected {0} bytes but only {1} bytes parsed for {2}.)r _DecodeVarintrread ValueErrorformat DESCRIPTORname)rr"rr parsed_sizes rparse_length_prefixedr+Os&   { +$ \  O' QY N'' (8(8(>?+D  vdK););)@)@A  .rc"|jS)zReturns the serialized size of this message. Args: message: A proto message. Returns: int: The number of bytes required to serialize this message. )rr s r byte_sizer.ws    rc$|jy)zfClears all data that was set in the message. Args: message: The proto message to be cleared. N)Clearr-s r clear_messager1s  --/r field_namec&|j|y)ahClears the contents of a given field. Inside a oneof group, clears the field set. If the name neither refers to a defined field or oneof group, :exc:`ValueError` is raised. Args: message: The proto message. field_name (str): The name of the field to be cleared. Raises: ValueError: if the `field_name` is not a member of this message. N) ClearField)r r2s r clear_fieldr5s Z r)N)__doc__iotypingrrrgoogle.protobuf.internalrrgoogle.protobuf.messagerr boolbytesrrBytesIOr!r+intr.r1r5rrr@s3 &&,,+ :Y / @x @ @ @ h % H x<%>%02 % %P w 3 7t ! !d !t !r