github.com/datastax/go-cassandra-native-protocol@v0.0.0-20220706104457-5e8aad05cf90/message/options.go (about) 1 // Copyright 2020 DataStax 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package message 16 17 import ( 18 "errors" 19 "fmt" 20 "io" 21 22 "github.com/datastax/go-cassandra-native-protocol/primitive" 23 ) 24 25 // Options is a request message to obtain supported features from the server. The response to such a request is 26 // Supported. 27 // +k8s:deepcopy-gen=true 28 // +k8s:deepcopy-gen:interfaces=github.com/datastax/go-cassandra-native-protocol/message.Message 29 type Options struct { 30 } 31 32 func (m *Options) IsResponse() bool { 33 return false 34 } 35 36 func (m *Options) GetOpCode() primitive.OpCode { 37 return primitive.OpCodeOptions 38 } 39 40 func (m *Options) String() string { 41 return "OPTIONS" 42 } 43 44 type optionsCodec struct{} 45 46 func (c *optionsCodec) Encode(msg Message, _ io.Writer, _ primitive.ProtocolVersion) error { 47 _, ok := msg.(*Options) 48 if !ok { 49 return errors.New(fmt.Sprintf("expected *message.Options, got %T", msg)) 50 } 51 return nil 52 } 53 54 func (c *optionsCodec) EncodedLength(msg Message, _ primitive.ProtocolVersion) (int, error) { 55 _, ok := msg.(*Options) 56 if !ok { 57 return -1, errors.New(fmt.Sprintf("expected *message.Options, got %T", msg)) 58 } 59 return 0, nil 60 } 61 62 func (c *optionsCodec) Decode(_ io.Reader, _ primitive.ProtocolVersion) (Message, error) { 63 return &Options{}, nil 64 } 65 66 func (c *optionsCodec) GetOpCode() primitive.OpCode { 67 return primitive.OpCodeOptions 68 }