server

package
v0.0.0-...-5372e75 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Overview

Package server is a generated twirp stub package. This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v5.10.1.

It is generated from these files:

service.proto

Index

Constants

View Source
const BluetoothPathPrefix = "/twirp/karaks.service.bluetooth.Bluetooth/"

BluetoothPathPrefix is used for all URL paths on a twirp Bluetooth server. Requests are always: POST BluetoothPathPrefix/method It can be used in an HTTP mux to route twirp requests along with non-twirp requests on other routes.

Variables

View Source
var (
	ErrInvalidLengthService        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowService          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupService = fmt.Errorf("proto: unexpected end of group")
)

Functions

func GenerateDeviceID

func GenerateDeviceID() string

func GenerateID

func GenerateID() string

func NewZeroConfChannel

func NewZeroConfChannel() chan bool

func RegisterService

func RegisterService(name string, port int, protocol string, ch chan bool, uuid ...string)

TODO: Re-register service

func WriteError

func WriteError(resp http.ResponseWriter, err error)

WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)

Types

type Adapter

type Adapter struct {
	Path                 string   `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	Name                 string   `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Alias                string   `protobuf:"bytes,3,opt,name=alias,proto3" json:"alias,omitempty"`
	Address              string   `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
	Discoverable         bool     `protobuf:"varint,5,opt,name=discoverable,proto3" json:"discoverable,omitempty"`
	Pairable             bool     `protobuf:"varint,6,opt,name=pairable,proto3" json:"pairable,omitempty"`
	Powered              bool     `protobuf:"varint,7,opt,name=powered,proto3" json:"powered,omitempty"`
	Discovering          bool     `protobuf:"varint,8,opt,name=discovering,proto3" json:"discovering,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Adapter) Descriptor

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

func (*Adapter) GetAddress

func (m *Adapter) GetAddress() string

func (*Adapter) GetAlias

func (m *Adapter) GetAlias() string

func (*Adapter) GetDiscoverable

func (m *Adapter) GetDiscoverable() bool

func (*Adapter) GetDiscovering

func (m *Adapter) GetDiscovering() bool

func (*Adapter) GetName

func (m *Adapter) GetName() string

func (*Adapter) GetPairable

func (m *Adapter) GetPairable() bool

func (*Adapter) GetPath

func (m *Adapter) GetPath() string

func (*Adapter) GetPowered

func (m *Adapter) GetPowered() bool

func (*Adapter) Marshal

func (m *Adapter) Marshal() (dAtA []byte, err error)

func (*Adapter) MarshalTo

func (m *Adapter) MarshalTo(dAtA []byte) (int, error)

func (*Adapter) MarshalToSizedBuffer

func (m *Adapter) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Adapter) ProtoMessage

func (*Adapter) ProtoMessage()

func (*Adapter) Reset

func (m *Adapter) Reset()

func (*Adapter) Size

func (m *Adapter) Size() (n int)

func (*Adapter) String

func (m *Adapter) String() string

func (*Adapter) Unmarshal

func (m *Adapter) Unmarshal(dAtA []byte) error

func (*Adapter) XXX_DiscardUnknown

func (m *Adapter) XXX_DiscardUnknown()

func (*Adapter) XXX_Marshal

func (m *Adapter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Adapter) XXX_Merge

func (m *Adapter) XXX_Merge(src proto.Message)

func (*Adapter) XXX_Size

func (m *Adapter) XXX_Size() int

func (*Adapter) XXX_Unmarshal

func (m *Adapter) XXX_Unmarshal(b []byte) error

type Adapters

type Adapters struct {
	Adapters             []*Adapter `protobuf:"bytes,1,rep,name=adapters,proto3" json:"adapters,omitempty"`
	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
	XXX_unrecognized     []byte     `json:"-"`
	XXX_sizecache        int32      `json:"-"`
}

func (*Adapters) Descriptor

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

func (*Adapters) GetAdapters

func (m *Adapters) GetAdapters() []*Adapter

func (*Adapters) Marshal

func (m *Adapters) Marshal() (dAtA []byte, err error)

func (*Adapters) MarshalTo

func (m *Adapters) MarshalTo(dAtA []byte) (int, error)

func (*Adapters) MarshalToSizedBuffer

func (m *Adapters) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Adapters) ProtoMessage

func (*Adapters) ProtoMessage()

func (*Adapters) Reset

func (m *Adapters) Reset()

func (*Adapters) Size

func (m *Adapters) Size() (n int)

func (*Adapters) String

func (m *Adapters) String() string

func (*Adapters) Unmarshal

func (m *Adapters) Unmarshal(dAtA []byte) error

func (*Adapters) XXX_DiscardUnknown

func (m *Adapters) XXX_DiscardUnknown()

func (*Adapters) XXX_Marshal

func (m *Adapters) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Adapters) XXX_Merge

func (m *Adapters) XXX_Merge(src proto.Message)

func (*Adapters) XXX_Size

func (m *Adapters) XXX_Size() int

func (*Adapters) XXX_Unmarshal

func (m *Adapters) XXX_Unmarshal(b []byte) error

type Bluetooth

type Bluetooth interface {
	ListDevices(context.Context, *Empty) (*Devices, error)

	ListAdapters(context.Context, *Empty) (*Adapters, error)

	Connect(context.Context, *Params) (*Adapters, error)

	Disconnect(context.Context, *Params) (*Adapters, error)

	Pair(context.Context, *Params) (*Adapters, error)

	EnableCard(context.Context, *Card) (*Status, error)

	StartDiscovery(context.Context, *Adapter) (*Status, error)

	StopDiscovery(context.Context, *Adapter) (*Status, error)
}

func NewBluetoothJSONClient

func NewBluetoothJSONClient(addr string, client HTTPClient, opts ...twirp.ClientOption) Bluetooth

NewBluetoothJSONClient creates a JSON client that implements the Bluetooth interface. It communicates using JSON and can be configured with a custom HTTPClient.

func NewBluetoothProtobufClient

func NewBluetoothProtobufClient(addr string, client HTTPClient, opts ...twirp.ClientOption) Bluetooth

NewBluetoothProtobufClient creates a Protobuf client that implements the Bluetooth interface. It communicates using Protobuf and can be configured with a custom HTTPClient.

type Card

type Card struct {
	Address              string   `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	Num                  int32    `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Card) Descriptor

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

func (*Card) GetAddress

func (m *Card) GetAddress() string

func (*Card) GetNum

func (m *Card) GetNum() int32

func (*Card) Marshal

func (m *Card) Marshal() (dAtA []byte, err error)

func (*Card) MarshalTo

func (m *Card) MarshalTo(dAtA []byte) (int, error)

func (*Card) MarshalToSizedBuffer

func (m *Card) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Card) ProtoMessage

func (*Card) ProtoMessage()

func (*Card) Reset

func (m *Card) Reset()

func (*Card) Size

func (m *Card) Size() (n int)

func (*Card) String

func (m *Card) String() string

func (*Card) Unmarshal

func (m *Card) Unmarshal(dAtA []byte) error

func (*Card) XXX_DiscardUnknown

func (m *Card) XXX_DiscardUnknown()

func (*Card) XXX_Marshal

func (m *Card) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Card) XXX_Merge

func (m *Card) XXX_Merge(src proto.Message)

func (*Card) XXX_Size

func (m *Card) XXX_Size() int

func (*Card) XXX_Unmarshal

func (m *Card) XXX_Unmarshal(b []byte) error

type Device

type Device struct {
	Path                 string   `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	Name                 string   `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	Alias                string   `protobuf:"bytes,3,opt,name=alias,proto3" json:"alias,omitempty"`
	Address              string   `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
	Adapter              string   `protobuf:"bytes,5,opt,name=adapter,proto3" json:"adapter,omitempty"`
	Paired               bool     `protobuf:"varint,6,opt,name=paired,proto3" json:"paired,omitempty"`
	Connected            bool     `protobuf:"varint,7,opt,name=connected,proto3" json:"connected,omitempty"`
	Trusted              bool     `protobuf:"varint,8,opt,name=trusted,proto3" json:"trusted,omitempty"`
	Blocked              bool     `protobuf:"varint,9,opt,name=blocked,proto3" json:"blocked,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Device) Descriptor

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

func (*Device) GetAdapter

func (m *Device) GetAdapter() string

func (*Device) GetAddress

func (m *Device) GetAddress() string

func (*Device) GetAlias

func (m *Device) GetAlias() string

func (*Device) GetBlocked

func (m *Device) GetBlocked() bool

func (*Device) GetConnected

func (m *Device) GetConnected() bool

func (*Device) GetName

func (m *Device) GetName() string

func (*Device) GetPaired

func (m *Device) GetPaired() bool

func (*Device) GetPath

func (m *Device) GetPath() string

func (*Device) GetTrusted

func (m *Device) GetTrusted() bool

func (*Device) Marshal

func (m *Device) Marshal() (dAtA []byte, err error)

func (*Device) MarshalTo

func (m *Device) MarshalTo(dAtA []byte) (int, error)

func (*Device) MarshalToSizedBuffer

func (m *Device) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Device) ProtoMessage

func (*Device) ProtoMessage()

func (*Device) Reset

func (m *Device) Reset()

func (*Device) Size

func (m *Device) Size() (n int)

func (*Device) String

func (m *Device) String() string

func (*Device) Unmarshal

func (m *Device) Unmarshal(dAtA []byte) error

func (*Device) XXX_DiscardUnknown

func (m *Device) XXX_DiscardUnknown()

func (*Device) XXX_Marshal

func (m *Device) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Device) XXX_Merge

func (m *Device) XXX_Merge(src proto.Message)

func (*Device) XXX_Size

func (m *Device) XXX_Size() int

func (*Device) XXX_Unmarshal

func (m *Device) XXX_Unmarshal(b []byte) error

type Devices

type Devices struct {
	Devices              []*Device `protobuf:"bytes,1,rep,name=devices,proto3" json:"devices,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*Devices) Descriptor

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

func (*Devices) GetDevices

func (m *Devices) GetDevices() []*Device

func (*Devices) Marshal

func (m *Devices) Marshal() (dAtA []byte, err error)

func (*Devices) MarshalTo

func (m *Devices) MarshalTo(dAtA []byte) (int, error)

func (*Devices) MarshalToSizedBuffer

func (m *Devices) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Devices) ProtoMessage

func (*Devices) ProtoMessage()

func (*Devices) Reset

func (m *Devices) Reset()

func (*Devices) Size

func (m *Devices) Size() (n int)

func (*Devices) String

func (m *Devices) String() string

func (*Devices) Unmarshal

func (m *Devices) Unmarshal(dAtA []byte) error

func (*Devices) XXX_DiscardUnknown

func (m *Devices) XXX_DiscardUnknown()

func (*Devices) XXX_Marshal

func (m *Devices) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Devices) XXX_Merge

func (m *Devices) XXX_Merge(src proto.Message)

func (*Devices) XXX_Size

func (m *Devices) XXX_Size() int

func (*Devices) XXX_Unmarshal

func (m *Devices) XXX_Unmarshal(b []byte) error

type Empty

type Empty struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Empty) Descriptor

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

func (*Empty) Marshal

func (m *Empty) Marshal() (dAtA []byte, err error)

func (*Empty) MarshalTo

func (m *Empty) MarshalTo(dAtA []byte) (int, error)

func (*Empty) MarshalToSizedBuffer

func (m *Empty) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) Size

func (m *Empty) Size() (n int)

func (*Empty) String

func (m *Empty) String() string

func (*Empty) Unmarshal

func (m *Empty) Unmarshal(dAtA []byte) error

func (*Empty) XXX_DiscardUnknown

func (m *Empty) XXX_DiscardUnknown()

func (*Empty) XXX_Marshal

func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Empty) XXX_Merge

func (m *Empty) XXX_Merge(src proto.Message)

func (*Empty) XXX_Size

func (m *Empty) XXX_Size() int

func (*Empty) XXX_Unmarshal

func (m *Empty) XXX_Unmarshal(b []byte) error

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.

type Params

type Params struct {
	Name                 string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Params) Descriptor

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

func (*Params) GetName

func (m *Params) GetName() string

func (*Params) Marshal

func (m *Params) Marshal() (dAtA []byte, err error)

func (*Params) MarshalTo

func (m *Params) MarshalTo(dAtA []byte) (int, error)

func (*Params) MarshalToSizedBuffer

func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Params) ProtoMessage

func (*Params) ProtoMessage()

func (*Params) Reset

func (m *Params) Reset()

func (*Params) Size

func (m *Params) Size() (n int)

func (*Params) String

func (m *Params) String() string

func (*Params) Unmarshal

func (m *Params) Unmarshal(dAtA []byte) error

func (*Params) XXX_DiscardUnknown

func (m *Params) XXX_DiscardUnknown()

func (*Params) XXX_Marshal

func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Params) XXX_Merge

func (m *Params) XXX_Merge(src proto.Message)

func (*Params) XXX_Size

func (m *Params) XXX_Size() int

func (*Params) XXX_Unmarshal

func (m *Params) XXX_Unmarshal(b []byte) error

type Server

type Server struct {
	B       *bluez.Bluez
	Adapter string
}

func (*Server) Connect

func (s *Server) Connect(ctx context.Context, req *Params) (res *Adapters, err error)

func (*Server) Disconnect

func (s *Server) Disconnect(ctx context.Context, req *Params) (res *Adapters, err error)

func (*Server) EnableCard

func (s *Server) EnableCard(ctx context.Context, req *Card) (res *Status, err error)

func (*Server) ListAdapters

func (s *Server) ListAdapters(ctx context.Context, req *Empty) (res *Adapters, err error)

func (*Server) ListDevices

func (s *Server) ListDevices(ctx context.Context, req *Empty) (res *Devices, err error)

func (*Server) Pair

func (s *Server) Pair(ctx context.Context, req *Params) (res *Adapters, err error)

func (Server) StartDiscovery

func (s Server) StartDiscovery(ctx context.Context, req *Adapter) (res *Status, err error)

func (Server) StopDiscovery

func (s Server) StopDiscovery(ctx context.Context, req *Adapter) (res *Status, err error)

type Status

type Status struct {
	Ok                   bool     `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Status) Descriptor

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

func (*Status) GetOk

func (m *Status) GetOk() bool

func (*Status) Marshal

func (m *Status) Marshal() (dAtA []byte, err error)

func (*Status) MarshalTo

func (m *Status) MarshalTo(dAtA []byte) (int, error)

func (*Status) MarshalToSizedBuffer

func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Status) ProtoMessage

func (*Status) ProtoMessage()

func (*Status) Reset

func (m *Status) Reset()

func (*Status) Size

func (m *Status) Size() (n int)

func (*Status) String

func (m *Status) String() string

func (*Status) Unmarshal

func (m *Status) Unmarshal(dAtA []byte) error

func (*Status) XXX_DiscardUnknown

func (m *Status) XXX_DiscardUnknown()

func (*Status) XXX_Marshal

func (m *Status) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Status) XXX_Merge

func (m *Status) XXX_Merge(src proto.Message)

func (*Status) XXX_Size

func (m *Status) XXX_Size() int

func (*Status) XXX_Unmarshal

func (m *Status) XXX_Unmarshal(b []byte) error

type TwirpServer

type TwirpServer interface {
	http.Handler
	// ServiceDescriptor returns gzipped bytes describing the .proto file that
	// this service was generated from. Once unzipped, the bytes can be
	// unmarshalled as a
	// github.com/golang/protobuf/protoc-gen-go/descriptor.FileDescriptorProto.
	//
	// The returned integer is the index of this particular service within that
	// FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a
	// low-level field, expected to be used for reflection.
	ServiceDescriptor() ([]byte, int)
	// ProtocGenTwirpVersion is the semantic version string of the version of
	// twirp used to generate this file.
	ProtocGenTwirpVersion() string
	// PathPrefix returns the HTTP URL path prefix for all methods handled by this
	// service. This can be used with an HTTP mux to route twirp requests
	// alongside non-twirp requests on one HTTP listener.
	PathPrefix() string
}

TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.

func NewBluetoothServer

func NewBluetoothServer(svc Bluetooth, hooks *twirp.ServerHooks) TwirpServer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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