Class: Solace::Serializers::InstructionSerializer

Inherits:
BaseSerializer show all
Defined in:
lib/solace/serializers/instruction_serializer.rb

Instance Attribute Summary

Attributes inherited from BaseSerializer

#record

Instance Method Summary collapse

Methods inherited from BaseSerializer

#call, #initialize

Methods inherited from Base

call, #call

Constructor Details

This class inherits a constructor from Solace::Serializers::BaseSerializer

Instance Method Details

#encode_accountsArray<Integer>

Encodes the accounts of the instruction

The BufferLayout is:

- [Number of accounts (compact u16)]
- [Accounts (variable length u8)]

Returns:

  • (Array<Integer>)

    The bytes of the encoded accounts



38
39
40
# File 'lib/solace/serializers/instruction_serializer.rb', line 38

def encode_accounts
  Codecs.encode_compact_u16(record.accounts.size).bytes + record.accounts
end

#encode_dataArray<Integer>

Encodes the data of the instruction

The BufferLayout is:

- [Number of data bytes (compact u16)]
- [Data bytes (variable length u8)]

Returns:

  • (Array<Integer>)

    The bytes of the encoded data



49
50
51
# File 'lib/solace/serializers/instruction_serializer.rb', line 49

def encode_data
  Codecs.encode_compact_u16(record.data.size).bytes + record.data
end

#encode_program_indexInteger

Encodes the program index of the instruction

The BufferLayout is:

- [Program index (u8)]

Returns:

  • (Integer)

    The bytes of the encoded program index



27
28
29
# File 'lib/solace/serializers/instruction_serializer.rb', line 27

def encode_program_index
  record.program_index
end