Function decode

  • You must configure the generic argument T.

    Protocol Buffer Decoder.

    typia.protobuf.decode() is a function decoding a binary data of Protocol Buffer format to a TypeScript instance.

    For reference, as Protocol Buffer handles binary data directly, there's no way when input binary data was not encoded from the T typed value. In that case, unexpected behavior or internal error would be occured. Therefore, I recommend you to encode binary data of Protocol Buffer from type safe encode functions like below. Use encode function only when you can ensure it.

    Also, typia is providing type safe decoders like assertDecode, but it is just for additional type validation like number & Minimum<7> or string & Format<"uuid"> cases, that are represented by custom tags. Thus, I repeat that, you've to ensure the type safety when using decoder functions.

    Parameters

    • input: Uint8Array

      Protobuf Buffer binary data

    Returns never

    Decoded value

    Jeongho Nam - https://github.com/samchon

  • Protocol Buffer Decoder.

    typia.protobuf.decode() is a function decoding a binary data of Protocol Buffer format to a TypeScript instance.

    For reference, as Protocol Buffer handles binary data directly, there's no way when input binary data was not encoded from the T typed value. In that case, unexpected behavior or internal error would be occured. Therefore, I recommend you to encode binary data of Protocol Buffer from type safe encode functions like below. Use encode function only when you can ensure it.

    Also, typia is providing type safe decoders like assertDecode, but it is just for additional type validation like number & Minimum<7> or string & Format<"uuid"> cases, that are represented by custom tags. Thus, I repeat that, you've to ensure the type safety when using decoder functions.

    Type Parameters

    • T

      Expected type of decoded value

    Parameters

    • input: Uint8Array

      Protobuf Buffer binary data

    Returns Resolved<T>

    Decoded value

    Jeongho Nam - https://github.com/samchon