Module: ActiveCypher::Bolt::Packstream
- Defined in:
- lib/active_cypher/bolt/packstream.rb
Overview
Handles Packstream serialization and deserialization. Based on Bolt Protocol Specification version 5.0 https://7687.org/bolt/bolt-protocol-specification-5.0.html#packstream-structures
Defined Under Namespace
Constant Summary collapse
- TINY_STRING_MARKER_BASE =
Marker Bytes & Limits
0x80- STRING_8_MARKER =
0xD0
- STRING_16_MARKER =
0xD1
- TINY_LIST_MARKER_BASE =
STRING_32_MARKER = 0xD2
0x90- LIST_8_MARKER =
Added List marker base
0xD4
- LIST_16_MARKER =
Added List marker
0xD5
- TINY_MAP_MARKER_BASE =
LIST_32_MARKER = 0xD6 # Added List marker STRING_32_MARKER = 0xD2 # Not implementing 32-bit sizes for now
0xA0
- MAP_8_MARKER =
0xD8
- MAP_16_MARKER =
0xD9
- INT_8 =
MAP_32_MARKER = 0xDA # Not implementing 32-bit sizes for now
0xC8
- INT_16 =
0xC9
- INT_32 =
0xCA
- INT_64 =
0xCB
- TINY_INT_MIN =
-16- TINY_INT_MAX =
127- INT_8_MIN =
-128- INT_8_MAX =
127- INT_16_MIN =
-32_768- INT_16_MAX =
32_767- INT_32_MIN =
-2_147_483_648- INT_32_MAX =
2_147_483_647
Class Method Summary collapse
-
.pack(value) ⇒ Object
Helper function to pack a value into a string.
-
.unpack(bytes) ⇒ Object
Helper function to unpack a value from a string.
Class Method Details
.pack(value) ⇒ Object
Helper function to pack a value into a string
305 306 307 308 309 310 |
# File 'lib/active_cypher/bolt/packstream.rb', line 305 def self.pack(value) io = StringIO.new(+'', 'wb') # Binary mode important packer = Packer.new(io) packer.pack(value) io.string end |
.unpack(bytes) ⇒ Object
Helper function to unpack a value from a string
313 314 315 316 317 |
# File 'lib/active_cypher/bolt/packstream.rb', line 313 def self.unpack(bytes) io = StringIO.new(bytes, 'rb') # Binary mode important unpacker = Unpacker.new(io) unpacker.unpack end |