Module: Ruact::Flight::RowEmitter

Defined in:
lib/ruact/flight/row_emitter.rb

Overview

Formats Flight wire format rows.

Text rows: <hex_id>:<tag><json_payload>n Binary rows: <hex_id>:<tag><hex_byte_length>,<binary_data> (no newline)

Class Method Summary collapse

Class Method Details

.error(id, error_json) ⇒ Object

An error row



21
22
23
# File 'lib/ruact/flight/row_emitter.rb', line 21

def self.error(id, error_json)
  "#{id.to_s(16)}:E#{error_json}\n"
end

.hint(code, model_json) ⇒ Object

A hint row — no ID, fire-and-forget preload signal



32
33
34
# File 'lib/ruact/flight/row_emitter.rb', line 32

def self.hint(code, model_json)
  ":H#{code}#{model_json}\n"
end

.import(id, metadata_json) ⇒ Object

An import row — tells the client where to load a “use client” module



16
17
18
# File 'lib/ruact/flight/row_emitter.rb', line 16

def self.import(id, )
  "#{id.to_s(16)}:I#{}\n"
end

.model(id, json) ⇒ Object

A plain model row (most elements, objects, arrays)



11
12
13
# File 'lib/ruact/flight/row_emitter.rb', line 11

def self.model(id, json)
  "#{id.to_s(16)}:#{json}\n"
end

.text(id, text) ⇒ Object

A large text row (binary framing, no trailing newline)



26
27
28
29
# File 'lib/ruact/flight/row_emitter.rb', line 26

def self.text(id, text)
  byte_length = text.bytesize
  "#{id.to_s(16)}:T#{byte_length.to_s(16)},#{text}"
end