echo_pb

package module
v0.0.0-...-b031e8a Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

echo_pb

Protobuf IDL codec sample.

Compile go into a C dynamic library

Set build parameters Config::use_goffi_cdylib to true

cargo build -Z unstable-options --out-dir .
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:{DIR}/fcplug/target/debug ./echo_pb

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_echo_pb_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type CBuffer

type CBuffer struct {
	// contains filtered or unexported fields
}

CBuffer Rust buffer for Go

func (CBuffer) AsBytes

func (b CBuffer) AsBytes() []byte

func (CBuffer) AsString

func (b CBuffer) AsString() string

func (CBuffer) Free

func (b CBuffer) Free()

Free free rust memory buffer, must be called!

func (CBuffer) Len

func (b CBuffer) Len() int

type Ping

type Ping struct {
	Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
	// contains filtered or unexported fields
}

func (*Ping) Descriptor deprecated

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

Deprecated: Use Ping.ProtoReflect.Descriptor instead.

func (*Ping) GetMsg

func (x *Ping) GetMsg() string

func (*Ping) ProtoMessage

func (*Ping) ProtoMessage()

func (*Ping) ProtoReflect

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

func (*Ping) Reset

func (x *Ping) Reset()

func (*Ping) String

func (x *Ping) String() string

type Pong

type Pong struct {
	Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"`
	// contains filtered or unexported fields
}

func (*Pong) Descriptor deprecated

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

Deprecated: Use Pong.ProtoReflect.Descriptor instead.

func (*Pong) GetMsg

func (x *Pong) GetMsg() string

func (*Pong) ProtoMessage

func (*Pong) ProtoMessage()

func (*Pong) ProtoReflect

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

func (*Pong) Reset

func (x *Pong) Reset()

func (*Pong) String

func (x *Pong) String() string

type ResultCode

type ResultCode = int8
const (
	RcNoError ResultCode = 0
	RcDecode  ResultCode = -1
	RcEncode  ResultCode = -2
	RcUnknown ResultCode = -128
)

type RustFfi

type RustFfi interface {
	EchoRs(req TBytes[*Ping]) RustFfiResult[Pong]
}
var GlobalRustFfi RustFfi = RustFfiImpl{}

type RustFfiImpl

type RustFfiImpl struct{}

func (RustFfiImpl) EchoRs

func (RustFfiImpl) EchoRs(req TBytes[*Ping]) RustFfiResult[Pong]

type RustFfiResult

type RustFfiResult[T any] struct {
	CBuffer
	Code ResultCode
	// contains filtered or unexported fields
}

RustFfiResult Rust FFI Result for Go NOTE: must call Free method to free rust memory buffer!

func (RustFfiResult[T]) AsError

func (r RustFfiResult[T]) AsError() error

AsError as an error NOTE: reference Rust memory buffer

func (RustFfiResult[T]) IsOk

func (r RustFfiResult[T]) IsOk() bool

func (RustFfiResult[T]) JsonUnmarshal

func (r RustFfiResult[T]) JsonUnmarshal() (*T, error)

JsonUnmarshal as json to unmarshal NOTE: maybe reference Rust memory buffer

func (RustFfiResult[T]) JsonUnmarshalUnchecked

func (r RustFfiResult[T]) JsonUnmarshalUnchecked() *T

JsonUnmarshalUnchecked as json to unmarshal NOTE: maybe reference Rust memory buffer

func (RustFfiResult[T]) PbUnmarshal

func (r RustFfiResult[T]) PbUnmarshal() (*T, error)

PbUnmarshal as protobuf to unmarshal NOTE: maybe reference Rust memory buffer

func (RustFfiResult[T]) PbUnmarshalUnchecked

func (r RustFfiResult[T]) PbUnmarshalUnchecked() *T

PbUnmarshalUnchecked as protobuf to unmarshal NOTE: maybe reference Rust memory buffer

func (RustFfiResult[T]) String

func (r RustFfiResult[T]) String() string

func (RustFfiResult[T]) Unmarshal

func (r RustFfiResult[T]) Unmarshal(unmarshal func([]byte, any) error) (*T, error)

Unmarshal unmarshal to object NOTE: maybe reference Rust memory buffer

func (RustFfiResult[T]) UnmarshalUnchecked

func (r RustFfiResult[T]) UnmarshalUnchecked(unmarshal func([]byte, any) error) *T

UnmarshalUnchecked unmarshal to object NOTE: maybe reference Rust memory buffer

type TBytes

type TBytes[T any] struct {
	// contains filtered or unexported fields
}

TBytes bytes with type marker

func TBytesFromBytes

func TBytesFromBytes[T any](bytes []byte) TBytes[T]

TBytesFromBytes new TBytes from bytes

func TBytesFromJson

func TBytesFromJson[T any](obj T) (TBytes[T], error)

func TBytesFromJsonUnchecked

func TBytesFromJsonUnchecked[T proto.Message](obj T) TBytes[T]

func TBytesFromPb

func TBytesFromPb[T proto.Message](obj T) (TBytes[T], error)

func TBytesFromPbUnchecked

func TBytesFromPbUnchecked[T proto.Message](obj T) TBytes[T]

func TBytesFromString

func TBytesFromString[T any](s string) TBytes[T]

TBytesFromString new TBytes from string

func (TBytes[T]) ForCBuffer

func (b TBytes[T]) ForCBuffer() (unsafe.Pointer, int)

func (TBytes[T]) JsonUnmarshal

func (b TBytes[T]) JsonUnmarshal() (*T, error)

JsonUnmarshal as json to unmarshal NOTE: maybe reference Rust memory buffer

func (TBytes[T]) JsonUnmarshalUnchecked

func (b TBytes[T]) JsonUnmarshalUnchecked() *T

JsonUnmarshalUnchecked as json to unmarshal NOTE: maybe reference Rust memory buffer

func (TBytes[T]) Len

func (b TBytes[T]) Len() int

func (TBytes[T]) PbUnmarshal

func (b TBytes[T]) PbUnmarshal() (*T, error)

PbUnmarshal as protobuf to unmarshal NOTE: maybe reference Rust memory buffer

func (TBytes[T]) PbUnmarshalUnchecked

func (b TBytes[T]) PbUnmarshalUnchecked() *T

PbUnmarshalUnchecked as protobuf to unmarshal NOTE: maybe reference Rust memory buffer

func (TBytes[T]) Unmarshal

func (b TBytes[T]) Unmarshal(unmarshal func([]byte, any) error) (*T, error)

Unmarshal unmarshal to object NOTE: maybe reference Rust memory buffer

func (TBytes[T]) UnmarshalUnchecked

func (b TBytes[T]) UnmarshalUnchecked(unmarshal func([]byte, any) error) *T

UnmarshalUnchecked unmarshal to object NOTE: maybe reference Rust memory buffer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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