proto

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2022 License: Unlicense Imports: 8 Imported by: 2

Documentation

Overview

Package proto is the protocol buffers specification and generated code package for based32

The extra `error.go` file provides helpers and missing elements from the generated code that make programming the protocol simpler.

Index

Constants

This section is empty.

Variables

View Source
var (
	Error_name = map[int32]string{
		0: "ZERO_LENGTH",
		1: "CHECK_FAILED",
		2: "NIL_SLICE",
		3: "CHECK_TOO_SHORT",
		4: "INCORRECT_HUMAN_READABLE_PART",
	}
	Error_value = map[string]int32{
		"ZERO_LENGTH":                   0,
		"CHECK_FAILED":                  1,
		"NIL_SLICE":                     2,
		"CHECK_TOO_SHORT":               3,
		"INCORRECT_HUMAN_READABLE_PART": 4,
	}
)

Enum value maps for Error.

View Source
var File_based32_proto protoreflect.FileDescriptor
View Source
var Transcriber_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "proto.Transcriber",
	HandlerType: (*TranscriberServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Encode",
			Handler:       _Transcriber_Encode_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
		{
			StreamName:    "Decode",
			Handler:       _Transcriber_Decode_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "based32.proto",
}

Transcriber_ServiceDesc is the grpc.ServiceDesc for Transcriber service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterTranscriberServer

func RegisterTranscriberServer(s grpc.ServiceRegistrar, srv TranscriberServer)

Types

type DecodeRequest

type DecodeRequest struct {
	IdNonce       uint64 `protobuf:"varint,1,opt,name=IdNonce,proto3" json:"IdNonce,omitempty"`
	EncodedString string `protobuf:"bytes,2,opt,name=EncodedString,proto3" json:"EncodedString,omitempty"`
	// contains filtered or unexported fields
}

func (*DecodeRequest) Descriptor deprecated

func (*DecodeRequest) Descriptor() ([]byte, []int)

Deprecated: Use DecodeRequest.ProtoReflect.Descriptor instead.

func (*DecodeRequest) GetEncodedString

func (x *DecodeRequest) GetEncodedString() string

func (*DecodeRequest) GetIdNonce

func (x *DecodeRequest) GetIdNonce() uint64

func (*DecodeRequest) ProtoMessage

func (*DecodeRequest) ProtoMessage()

func (*DecodeRequest) ProtoReflect

func (x *DecodeRequest) ProtoReflect() protoreflect.Message

func (*DecodeRequest) Reset

func (x *DecodeRequest) Reset()

func (*DecodeRequest) String

func (x *DecodeRequest) String() string

type DecodeRes

type DecodeRes struct {
	IdNonce uint64
	Bytes   []byte
	Error   error
}

DecodeRes makes a more convenient return type for the results

type DecodeResponse

type DecodeResponse struct {
	IdNonce uint64 `protobuf:"varint,1,opt,name=IdNonce,proto3" json:"IdNonce,omitempty"`
	// Types that are assignable to Decoded:
	//	*DecodeResponse_Data
	//	*DecodeResponse_Error
	Decoded isDecodeResponse_Decoded `protobuf_oneof:"Decoded"`
	// contains filtered or unexported fields
}

func CreateDecodeResponse

func CreateDecodeResponse(res DecodeRes) (response *DecodeResponse)

CreateDecodeResponse is a helper to turn a proto.DecodeRes into an DecodeResponse to be returned to a gRPC client.

func (*DecodeResponse) Descriptor deprecated

func (*DecodeResponse) Descriptor() ([]byte, []int)

Deprecated: Use DecodeResponse.ProtoReflect.Descriptor instead.

func (*DecodeResponse) GetData

func (x *DecodeResponse) GetData() []byte

func (*DecodeResponse) GetDecoded

func (m *DecodeResponse) GetDecoded() isDecodeResponse_Decoded

func (*DecodeResponse) GetError

func (x *DecodeResponse) GetError() Error

func (*DecodeResponse) GetIdNonce

func (x *DecodeResponse) GetIdNonce() uint64

func (*DecodeResponse) ProtoMessage

func (*DecodeResponse) ProtoMessage()

func (*DecodeResponse) ProtoReflect

func (x *DecodeResponse) ProtoReflect() protoreflect.Message

func (*DecodeResponse) Reset

func (x *DecodeResponse) Reset()

func (*DecodeResponse) String

func (x *DecodeResponse) String() string

type DecodeResponse_Data

type DecodeResponse_Data struct {
	Data []byte `protobuf:"bytes,2,opt,name=Data,proto3,oneof"`
}

type DecodeResponse_Error

type DecodeResponse_Error struct {
	Error Error `protobuf:"varint,3,opt,name=Error,proto3,enum=proto.Error,oneof"`
}

type EncodeRequest

type EncodeRequest struct {
	IdNonce uint64 `protobuf:"varint,1,opt,name=IdNonce,proto3" json:"IdNonce,omitempty"`
	Data    []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
	// contains filtered or unexported fields
}

func (*EncodeRequest) Descriptor deprecated

func (*EncodeRequest) Descriptor() ([]byte, []int)

Deprecated: Use EncodeRequest.ProtoReflect.Descriptor instead.

func (*EncodeRequest) GetData

func (x *EncodeRequest) GetData() []byte

func (*EncodeRequest) GetIdNonce

func (x *EncodeRequest) GetIdNonce() uint64

func (*EncodeRequest) ProtoMessage

func (*EncodeRequest) ProtoMessage()

func (*EncodeRequest) ProtoReflect

func (x *EncodeRequest) ProtoReflect() protoreflect.Message

func (*EncodeRequest) Reset

func (x *EncodeRequest) Reset()

func (*EncodeRequest) String

func (x *EncodeRequest) String() string

type EncodeRes

type EncodeRes struct {
	IdNonce uint64
	String  string
	Error   error
}

EncodeRes makes a more convenient return type for the results

type EncodeResponse

type EncodeResponse struct {
	IdNonce uint64 `protobuf:"varint,1,opt,name=IdNonce,proto3" json:"IdNonce,omitempty"`
	// Types that are assignable to Encoded:
	//	*EncodeResponse_EncodedString
	//	*EncodeResponse_Error
	Encoded isEncodeResponse_Encoded `protobuf_oneof:"Encoded"`
	// contains filtered or unexported fields
}

func CreateEncodeResponse

func CreateEncodeResponse(res EncodeRes) (response *EncodeResponse)

CreateEncodeResponse is a helper to turn a proto.EncodeRes into an EncodeResponse to be returned to a gRPC client.

func (*EncodeResponse) Descriptor deprecated

func (*EncodeResponse) Descriptor() ([]byte, []int)

Deprecated: Use EncodeResponse.ProtoReflect.Descriptor instead.

func (*EncodeResponse) GetEncoded

func (m *EncodeResponse) GetEncoded() isEncodeResponse_Encoded

func (*EncodeResponse) GetEncodedString

func (x *EncodeResponse) GetEncodedString() string

func (*EncodeResponse) GetError

func (x *EncodeResponse) GetError() Error

func (*EncodeResponse) GetIdNonce

func (x *EncodeResponse) GetIdNonce() uint64

func (*EncodeResponse) ProtoMessage

func (*EncodeResponse) ProtoMessage()

func (*EncodeResponse) ProtoReflect

func (x *EncodeResponse) ProtoReflect() protoreflect.Message

func (*EncodeResponse) Reset

func (x *EncodeResponse) Reset()

func (*EncodeResponse) String

func (x *EncodeResponse) String() string

type EncodeResponse_EncodedString

type EncodeResponse_EncodedString struct {
	EncodedString string `protobuf:"bytes,2,opt,name=EncodedString,proto3,oneof"`
}

type EncodeResponse_Error

type EncodeResponse_Error struct {
	Error Error `protobuf:"varint,3,opt,name=Error,proto3,enum=proto.Error,oneof"`
}

type Error

type Error int32
const (
	Error_ZERO_LENGTH                   Error = 0
	Error_CHECK_FAILED                  Error = 1
	Error_NIL_SLICE                     Error = 2
	Error_CHECK_TOO_SHORT               Error = 3
	Error_INCORRECT_HUMAN_READABLE_PART Error = 4
)

func (Error) Descriptor

func (Error) Descriptor() protoreflect.EnumDescriptor

func (Error) Enum

func (x Error) Enum() *Error

func (Error) EnumDescriptor deprecated

func (Error) EnumDescriptor() ([]byte, []int)

Deprecated: Use Error.Descriptor instead.

func (Error) Error

func (x Error) Error() string

Error implements the Error interface which allows this error to automatically generate from the error code.

Fixes a bug in the generated code, which not only lacks the Error method it uses int32 for the error string map when it should be using the defined Error type. No easy way to report the bug in the code.

With this method implemented, one can simply return the error map code protos.Error_ERROR_NAME_HERE and logs print this upper case snake case which means it can be written to be informative in the proto file and concise in usage, and with this tiny additional helper, very easy to return, and print.

func (Error) Number

func (x Error) Number() protoreflect.EnumNumber

func (Error) String

func (x Error) String() string

func (Error) Type

func (Error) Type() protoreflect.EnumType

type TranscriberClient

type TranscriberClient interface {
	Encode(ctx context.Context, opts ...grpc.CallOption) (Transcriber_EncodeClient, error)
	Decode(ctx context.Context, opts ...grpc.CallOption) (Transcriber_DecodeClient, error)
}

TranscriberClient is the client API for Transcriber service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type TranscriberServer

type TranscriberServer interface {
	Encode(Transcriber_EncodeServer) error
	Decode(Transcriber_DecodeServer) error
	// contains filtered or unexported methods
}

TranscriberServer is the server API for Transcriber service. All implementations must embed UnimplementedTranscriberServer for forward compatibility

type Transcriber_DecodeClient

type Transcriber_DecodeClient interface {
	Send(*DecodeRequest) error
	Recv() (*DecodeResponse, error)
	grpc.ClientStream
}

type Transcriber_DecodeServer

type Transcriber_DecodeServer interface {
	Send(*DecodeResponse) error
	Recv() (*DecodeRequest, error)
	grpc.ServerStream
}

type Transcriber_EncodeClient

type Transcriber_EncodeClient interface {
	Send(*EncodeRequest) error
	Recv() (*EncodeResponse, error)
	grpc.ClientStream
}

type Transcriber_EncodeServer

type Transcriber_EncodeServer interface {
	Send(*EncodeResponse) error
	Recv() (*EncodeRequest, error)
	grpc.ServerStream
}

type UnimplementedTranscriberServer

type UnimplementedTranscriberServer struct {
}

UnimplementedTranscriberServer must be embedded to have forward compatible implementations.

func (UnimplementedTranscriberServer) Decode

func (UnimplementedTranscriberServer) Encode

type UnsafeTranscriberServer

type UnsafeTranscriberServer interface {
	// contains filtered or unexported methods
}

UnsafeTranscriberServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to TranscriberServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL