Class: Solace::Serializers::InstructionDeserializer

Inherits:
BaseDeserializer show all
Defined in:
lib/solace/serializers/instruction_deserializer.rb

Overview

Deserializes a binary instruction into a Solace::Instruction object.

Since:

  • 0.0.1

Instance Attribute Summary

Attributes inherited from BaseDeserializer

#io, #record

Instance Method Summary collapse

Methods inherited from BaseDeserializer

#call, #initialize

Constructor Details

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

Instance Method Details

#next_extract_accountsArray

Extracts the accounts from the instruction

The BufferLayout is:

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

Returns:

  • (Array)

    The accounts

Since:

  • 0.0.1



42
43
44
45
# File 'lib/solace/serializers/instruction_deserializer.rb', line 42

def next_extract_accounts
  length, = Codecs.decode_compact_u16(io)
  record.accounts = io.read(length).unpack('C*')
end

#next_extract_dataArray

Extracts the instruction data from the instruction

The BufferLayout is:

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

Returns:

  • (Array)

    The instruction data

Since:

  • 0.0.1



54
55
56
57
# File 'lib/solace/serializers/instruction_deserializer.rb', line 54

def next_extract_data
  length, = Codecs.decode_compact_u16(io)
  record.data = io.read(length).unpack('C*')
end

#next_extract_program_indexInteger

Extracts the program index from the instruction

The BufferLayout is:

- [Program index (1 byte)]

Returns:

  • (Integer)

    The program index

Since:

  • 0.0.1



31
32
33
# File 'lib/solace/serializers/instruction_deserializer.rb', line 31

def next_extract_program_index
  record.program_index = io.read(1).ord
end