| 181 | } |
| 182 | |
| 183 | func (c *partialExecuteCodec) Decode(source io.Reader, version primitive.ProtocolVersion) (msg message.Message, err error) { |
| 184 | var ( |
| 185 | queryId []byte |
| 186 | resultMetadataId []byte |
| 187 | consistency uint16 |
| 188 | ) |
| 189 | |
| 190 | reader, err := toFrameBodyReader(source) |
| 191 | if err != nil { |
| 192 | return nil, err |
| 193 | } |
| 194 | |
| 195 | if queryId, err = primitive.ReadShortBytes(reader); err != nil { |
| 196 | return nil, fmt.Errorf("cannot read EXECUTE query id: %w", err) |
| 197 | } else if len(queryId) == 0 { |
| 198 | return nil, errors.New("EXECUTE missing query id") |
| 199 | } |
| 200 | |
| 201 | if version >= primitive.ProtocolVersion5 { |
| 202 | if resultMetadataId, err = primitive.ReadShortBytes(reader); err != nil { |
| 203 | return nil, fmt.Errorf("cannot read EXECUTE result metadata id: %w", err) |
| 204 | } |
| 205 | |
| 206 | if len(resultMetadataId) == 0 { |
| 207 | return nil, errors.New("EXECUTE missing result metadata id") |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | if consistency, err = primitive.ReadShort(reader); err != nil { |
| 212 | return nil, fmt.Errorf("cannot read EXECUTE consistency level: %w", err) |
| 213 | } |
| 214 | |
| 215 | return &PartialExecute{ |
| 216 | QueryId: queryId, |
| 217 | Consistency: primitive.ConsistencyLevel(consistency), |
| 218 | Parameters: reader.RemainingBytes(), |
| 219 | }, nil |
| 220 | } |
| 221 | |
| 222 | func (c *partialExecuteCodec) GetOpCode() primitive.OpCode { |
| 223 | return primitive.OpCodeExecute |