msgpack 1.5.6 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +50 -0
- data/README.md +48 -12
- data/ext/java/org/msgpack/jruby/Buffer.java +3 -3
- data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +11 -20
- data/ext/java/org/msgpack/jruby/ExtensionValue.java +1 -1
- data/ext/java/org/msgpack/jruby/Factory.java +11 -50
- data/ext/java/org/msgpack/jruby/Packer.java +9 -24
- data/ext/java/org/msgpack/jruby/Unpacker.java +15 -32
- data/ext/msgpack/buffer.c +69 -56
- data/ext/msgpack/buffer.h +138 -44
- data/ext/msgpack/buffer_class.c +132 -31
- data/ext/msgpack/buffer_class.h +1 -0
- data/ext/msgpack/extconf.rb +20 -30
- data/ext/msgpack/factory_class.c +75 -86
- data/ext/msgpack/packer.c +13 -16
- data/ext/msgpack/packer.h +24 -21
- data/ext/msgpack/packer_class.c +72 -98
- data/ext/msgpack/packer_class.h +11 -0
- data/ext/msgpack/packer_ext_registry.c +31 -28
- data/ext/msgpack/packer_ext_registry.h +10 -14
- data/ext/msgpack/rbinit.c +1 -1
- data/ext/msgpack/rmem.c +3 -4
- data/ext/msgpack/sysdep.h +5 -2
- data/ext/msgpack/unpacker.c +201 -113
- data/ext/msgpack/unpacker.h +22 -15
- data/ext/msgpack/unpacker_class.c +87 -92
- data/ext/msgpack/unpacker_class.h +11 -0
- data/ext/msgpack/unpacker_ext_registry.c +4 -16
- data/ext/msgpack/unpacker_ext_registry.h +3 -7
- data/lib/msgpack/buffer.rb +9 -0
- data/lib/msgpack/factory.rb +90 -63
- data/lib/msgpack/packer.rb +10 -1
- data/lib/msgpack/unpacker.rb +14 -1
- data/lib/msgpack/version.rb +1 -1
- data/lib/msgpack.rb +1 -0
- data/msgpack.gemspec +8 -3
- metadata +21 -51
- data/.github/workflows/ci.yaml +0 -57
- data/.gitignore +0 -23
- data/.rubocop.yml +0 -36
- data/Gemfile +0 -9
- data/Rakefile +0 -70
- data/appveyor.yml +0 -18
- data/bench/bench.rb +0 -78
- data/doclib/msgpack/buffer.rb +0 -193
- data/doclib/msgpack/core_ext.rb +0 -101
- data/doclib/msgpack/error.rb +0 -19
- data/doclib/msgpack/extension_value.rb +0 -9
- data/doclib/msgpack/factory.rb +0 -145
- data/doclib/msgpack/packer.rb +0 -209
- data/doclib/msgpack/time.rb +0 -22
- data/doclib/msgpack/timestamp.rb +0 -44
- data/doclib/msgpack/unpacker.rb +0 -183
- data/doclib/msgpack.rb +0 -87
- data/msgpack.org.md +0 -46
- data/spec/bigint_spec.rb +0 -26
- data/spec/cases.json +0 -1
- data/spec/cases.msg +0 -0
- data/spec/cases_compact.msg +0 -0
- data/spec/cases_spec.rb +0 -39
- data/spec/cruby/buffer_io_spec.rb +0 -255
- data/spec/cruby/buffer_packer.rb +0 -29
- data/spec/cruby/buffer_spec.rb +0 -575
- data/spec/cruby/buffer_unpacker.rb +0 -19
- data/spec/cruby/unpacker_spec.rb +0 -70
- data/spec/ext_value_spec.rb +0 -99
- data/spec/exttypes.rb +0 -51
- data/spec/factory_spec.rb +0 -688
- data/spec/format_spec.rb +0 -301
- data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
- data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
- data/spec/jruby/unpacker_spec.rb +0 -186
- data/spec/msgpack_spec.rb +0 -214
- data/spec/pack_spec.rb +0 -61
- data/spec/packer_spec.rb +0 -575
- data/spec/random_compat.rb +0 -24
- data/spec/spec_helper.rb +0 -71
- data/spec/timestamp_spec.rb +0 -159
- data/spec/unpack_spec.rb +0 -57
- data/spec/unpacker_spec.rb +0 -859
data/bench/bench.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# % bundle install
|
2
|
-
# % bundle exec ruby bench/bench.rb
|
3
|
-
|
4
|
-
require 'msgpack'
|
5
|
-
|
6
|
-
require 'benchmark/ips'
|
7
|
-
|
8
|
-
object_plain = {
|
9
|
-
'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"'
|
10
|
-
}
|
11
|
-
|
12
|
-
data_plain = MessagePack.pack(object_plain)
|
13
|
-
|
14
|
-
object_structured = {
|
15
|
-
'remote_host' => '127.0.0.1',
|
16
|
-
'remote_user' => '-',
|
17
|
-
'date' => '10/Oct/2000:13:55:36 -0700',
|
18
|
-
'request' => 'GET /apache_pb.gif HTTP/1.0',
|
19
|
-
'method' => 'GET',
|
20
|
-
'path' => '/apache_pb.gif',
|
21
|
-
'protocol' => 'HTTP/1.0',
|
22
|
-
'status' => 200,
|
23
|
-
'bytes' => 2326,
|
24
|
-
'referer' => 'http://www.example.com/start.html',
|
25
|
-
'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
|
26
|
-
}
|
27
|
-
|
28
|
-
data_structured = MessagePack.pack(object_structured)
|
29
|
-
|
30
|
-
class Extended
|
31
|
-
def to_msgpack_ext
|
32
|
-
MessagePack.pack({})
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.from_msgpack_ext(data)
|
36
|
-
MessagePack.unpack(data)
|
37
|
-
Extended.new
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
object_extended = {
|
42
|
-
'extended' => Extended.new
|
43
|
-
}
|
44
|
-
|
45
|
-
extended_packer = MessagePack::Packer.new
|
46
|
-
extended_packer.register_type(0x00, Extended, :to_msgpack_ext)
|
47
|
-
data_extended = extended_packer.pack(object_extended).to_s
|
48
|
-
|
49
|
-
Benchmark.ips do |x|
|
50
|
-
x.report('pack-plain') do
|
51
|
-
MessagePack.pack(object_plain)
|
52
|
-
end
|
53
|
-
|
54
|
-
x.report('pack-structured') do
|
55
|
-
MessagePack.pack(object_structured)
|
56
|
-
end
|
57
|
-
|
58
|
-
x.report('pack-extended') do
|
59
|
-
packer = MessagePack::Packer.new
|
60
|
-
packer.register_type(0x00, Extended, :to_msgpack_ext)
|
61
|
-
packer.pack(object_extended).to_s
|
62
|
-
end
|
63
|
-
|
64
|
-
x.report('unpack-plain') do
|
65
|
-
MessagePack.unpack(data_plain)
|
66
|
-
end
|
67
|
-
|
68
|
-
x.report('unpack-structured') do
|
69
|
-
MessagePack.unpack(data_structured)
|
70
|
-
end
|
71
|
-
|
72
|
-
x.report('unpack-extended') do
|
73
|
-
unpacker = MessagePack::Unpacker.new
|
74
|
-
unpacker.register_type(0x00, Extended, :from_msgpack_ext)
|
75
|
-
unpacker.feed data_extended
|
76
|
-
unpacker.read
|
77
|
-
end
|
78
|
-
end
|
data/doclib/msgpack/buffer.rb
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
module MessagePack
|
2
|
-
|
3
|
-
class Buffer
|
4
|
-
#
|
5
|
-
# Creates a MessagePack::Buffer instance.
|
6
|
-
#
|
7
|
-
# @overload initialize(options={})
|
8
|
-
# @param options [Hash]
|
9
|
-
#
|
10
|
-
# @overload initialize(io, options={})
|
11
|
-
# @param io [IO]
|
12
|
-
# @param options [Hash]
|
13
|
-
# This buffer writes written data into the IO when it is filled.
|
14
|
-
# This buffer reads data from the IO when it is empty.
|
15
|
-
#
|
16
|
-
# _io_ must respond to readpartial(length, [,string]) or read(string) method and
|
17
|
-
# write(string) or append(string) method.
|
18
|
-
#
|
19
|
-
# Supported options:
|
20
|
-
#
|
21
|
-
# * *:io_buffer_size* buffer size to read data from the internal IO. (default: 32768)
|
22
|
-
# * *:read_reference_threshold* the threshold size to enable zero-copy deserialize optimization. Read strings longer than this threshold will refer the original string instead of copying it. (default: 256) (supported in MRI only)
|
23
|
-
# * *:write_reference_threshold* the threshold size to enable zero-copy serialize optimization. The buffer refers written strings longer than this threshold instead of copying it. (default: 524288) (supported in MRI only)
|
24
|
-
#
|
25
|
-
def initialize(*args)
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# Makes the buffer empty
|
30
|
-
#
|
31
|
-
# @return nil
|
32
|
-
#
|
33
|
-
def clear
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# Returns byte size of the buffer.
|
38
|
-
#
|
39
|
-
# @return nil
|
40
|
-
#
|
41
|
-
def size
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# Returns _true_ if the buffer is empty.
|
46
|
-
# This method is slightly faster than _size_.
|
47
|
-
#
|
48
|
-
# @return [Boolean]
|
49
|
-
#
|
50
|
-
def empty?
|
51
|
-
end
|
52
|
-
|
53
|
-
#
|
54
|
-
# Appends the given data to the buffer.
|
55
|
-
#
|
56
|
-
# @param data [String]
|
57
|
-
# @return [Integer] byte size written
|
58
|
-
#
|
59
|
-
def write(data)
|
60
|
-
end
|
61
|
-
|
62
|
-
#
|
63
|
-
# Appends the given data to the buffer.
|
64
|
-
#
|
65
|
-
# @param data [String]
|
66
|
-
# @return [Buffer] self
|
67
|
-
#
|
68
|
-
def <<(data)
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Consumes _n_ bytes from the head of the buffer and returns consumed data.
|
73
|
-
# If the size of the buffer is less than _n_, it reads all of data in the buffer.
|
74
|
-
#
|
75
|
-
# If _n_ is 0, it does nothing and returns an empty string.
|
76
|
-
# If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
|
77
|
-
#
|
78
|
-
# @overload read
|
79
|
-
#
|
80
|
-
# @overload read(n)
|
81
|
-
# @param n [Integer] bytes to read
|
82
|
-
#
|
83
|
-
# @overload read(n, buffer)
|
84
|
-
# @param n [Integer] bytes to read
|
85
|
-
# @param buffer [String] buffer to read into
|
86
|
-
#
|
87
|
-
# @return [String]
|
88
|
-
#
|
89
|
-
def read(n)
|
90
|
-
end
|
91
|
-
|
92
|
-
#
|
93
|
-
# Consumes _n_ bytes from the head of the buffer and returns consumed data.
|
94
|
-
# If the size of the buffer is less than _n_, it does nothing and raises EOFError.
|
95
|
-
#
|
96
|
-
# If _n_ is 0, it does nothing and returns an empty string.
|
97
|
-
# If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
|
98
|
-
#
|
99
|
-
# @overload read_all
|
100
|
-
#
|
101
|
-
# @overload read_all(n)
|
102
|
-
# @param n [Integer] bytes to read
|
103
|
-
#
|
104
|
-
# @overload read_all(n, buffer)
|
105
|
-
# @param n [Integer] bytes to read
|
106
|
-
# @param buffer [String] buffer to read into
|
107
|
-
#
|
108
|
-
# @return [String]
|
109
|
-
#
|
110
|
-
def read_all(n, buffer=nil)
|
111
|
-
end
|
112
|
-
|
113
|
-
#
|
114
|
-
# Consumes _n_ bytes from the head of the buffer.
|
115
|
-
# If the size of the buffer is less than _n_, it skips all of data in the buffer and returns integer less than _n_.
|
116
|
-
#
|
117
|
-
# If _n_ is 0, it does nothing and returns _0_.
|
118
|
-
#
|
119
|
-
# @param n [Integer] byte size to skip
|
120
|
-
# @return [Integer] byte size actually skipped
|
121
|
-
#
|
122
|
-
def skip(n)
|
123
|
-
end
|
124
|
-
|
125
|
-
#
|
126
|
-
# Consumes _n_ bytes from the head of the buffer.
|
127
|
-
# If the size of the buffer is less than _n_, it does nothing and raises EOFError.
|
128
|
-
# If _n_ is 0, it does nothing.
|
129
|
-
#
|
130
|
-
# @param n [Integer] byte size to skip
|
131
|
-
# @return [Buffer] self
|
132
|
-
#
|
133
|
-
def skip_all(n)
|
134
|
-
end
|
135
|
-
|
136
|
-
#
|
137
|
-
# Returns all data in the buffer as a string.
|
138
|
-
# Destructive update to the returned string does NOT effect the buffer.
|
139
|
-
#
|
140
|
-
# @return [String]
|
141
|
-
#
|
142
|
-
def to_str
|
143
|
-
end
|
144
|
-
|
145
|
-
#
|
146
|
-
# Returns content of the buffer as an array of strings.
|
147
|
-
#
|
148
|
-
# This method is sometimes faster than to_s because the internal
|
149
|
-
# structure of the buffer is a queue of buffer chunks.
|
150
|
-
#
|
151
|
-
# @return [Array] array of strings
|
152
|
-
#
|
153
|
-
def to_a
|
154
|
-
end
|
155
|
-
|
156
|
-
#
|
157
|
-
# Internal io
|
158
|
-
#
|
159
|
-
# @return IO
|
160
|
-
#
|
161
|
-
attr_reader :io
|
162
|
-
|
163
|
-
#
|
164
|
-
# Flushes data in the internal buffer to the internal IO.
|
165
|
-
# If internal IO is not set, it does nothing.
|
166
|
-
#
|
167
|
-
# @return [Buffer] self
|
168
|
-
#
|
169
|
-
def flush
|
170
|
-
end
|
171
|
-
|
172
|
-
#
|
173
|
-
# Closes internal IO if its set.
|
174
|
-
# If internal IO is not set, it does nothing
|
175
|
-
#
|
176
|
-
# @return nil
|
177
|
-
#
|
178
|
-
def close
|
179
|
-
end
|
180
|
-
|
181
|
-
#
|
182
|
-
# Writes all of data in the internal buffer into the given IO.
|
183
|
-
# This method consumes and removes data from the internal buffer.
|
184
|
-
# _io_ must respond to write(data) method.
|
185
|
-
#
|
186
|
-
# @param io [IO]
|
187
|
-
# @return [Integer] byte size of written data
|
188
|
-
#
|
189
|
-
def write_to(io)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|
data/doclib/msgpack/core_ext.rb
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
|
2
|
-
class NilClass
|
3
|
-
#
|
4
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
5
|
-
#
|
6
|
-
# @return [String] serialized data
|
7
|
-
#
|
8
|
-
def to_msgpack(packer=nil)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class TrueClass
|
13
|
-
#
|
14
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
15
|
-
#
|
16
|
-
# @return [String] serialized data
|
17
|
-
#
|
18
|
-
def to_msgpack(packer=nil)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class FalseClass
|
23
|
-
#
|
24
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
25
|
-
#
|
26
|
-
# @return [String] serialized data
|
27
|
-
#
|
28
|
-
def to_msgpack(packer=nil)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Fixnum < Integer
|
33
|
-
#
|
34
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
35
|
-
#
|
36
|
-
# @return [String] serialized data
|
37
|
-
#
|
38
|
-
def to_msgpack(packer=nil)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class Bignum < Integer
|
43
|
-
#
|
44
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
45
|
-
#
|
46
|
-
# @return [String] serialized data
|
47
|
-
#
|
48
|
-
def to_msgpack(packer=nil)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class Float < Numeric
|
53
|
-
#
|
54
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
55
|
-
#
|
56
|
-
# @return [String] serialized data
|
57
|
-
#
|
58
|
-
def to_msgpack(packer=nil)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class String
|
63
|
-
#
|
64
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
65
|
-
#
|
66
|
-
# @return [String] serialized data
|
67
|
-
#
|
68
|
-
def to_msgpack(packer=nil)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
class Array
|
73
|
-
#
|
74
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
75
|
-
#
|
76
|
-
# @return [String] serialized data
|
77
|
-
#
|
78
|
-
def to_msgpack(packer=nil)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
class Hash
|
83
|
-
#
|
84
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
85
|
-
#
|
86
|
-
# @return [String] serialized data
|
87
|
-
#
|
88
|
-
def to_msgpack(packer=nil)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
class Symbol
|
93
|
-
#
|
94
|
-
# Same as MessagePack.to_msgpack(self[, packer]).
|
95
|
-
#
|
96
|
-
# @return [String] serialized data
|
97
|
-
#
|
98
|
-
def to_msgpack(packer=nil)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
data/doclib/msgpack/error.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module MessagePack
|
2
|
-
|
3
|
-
class UnpackError < StandardError
|
4
|
-
end
|
5
|
-
|
6
|
-
class MalformedFormatError < UnpackError
|
7
|
-
end
|
8
|
-
|
9
|
-
class StackError < UnpackError
|
10
|
-
end
|
11
|
-
|
12
|
-
class UnexpectedTypeError < UnpackError
|
13
|
-
include TypeError
|
14
|
-
end
|
15
|
-
|
16
|
-
class UnknownExtTypeError < UnpackError
|
17
|
-
include TypeError
|
18
|
-
end
|
19
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module MessagePack
|
2
|
-
|
3
|
-
#
|
4
|
-
# MessagePack::ExtensionValue is a struct to represent unknown ext type object.
|
5
|
-
# Its contents are accessed by type and payload (messagepack bytes representation) methods.
|
6
|
-
# And it is extended to add to_msgpack object.
|
7
|
-
#
|
8
|
-
ExtensionValue = Struct.new(:type, :payload)
|
9
|
-
end
|
data/doclib/msgpack/factory.rb
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
module MessagePack
|
2
|
-
#
|
3
|
-
# MessagePack::Factory is a class to generate Packer and Unpacker which has
|
4
|
-
# same set of ext types.
|
5
|
-
#
|
6
|
-
class Factory
|
7
|
-
#
|
8
|
-
# Creates a MessagePack::Factory instance
|
9
|
-
#
|
10
|
-
def initialize
|
11
|
-
end
|
12
|
-
|
13
|
-
#
|
14
|
-
# Creates a MessagePack::Packer instance, which has ext types already registered.
|
15
|
-
# Options are passed to MessagePack::Packer#initialized.
|
16
|
-
#
|
17
|
-
# See also Packer#initialize for options.
|
18
|
-
#
|
19
|
-
def packer(*args)
|
20
|
-
end
|
21
|
-
|
22
|
-
#
|
23
|
-
# Serialize the passed value
|
24
|
-
#
|
25
|
-
# If it could not serialize the object, it raises
|
26
|
-
# NoMethodError: undefined method `to_msgpack' for #<the_object>.
|
27
|
-
#
|
28
|
-
# @param obj [Object] object to serialize
|
29
|
-
# @param options [Hash]
|
30
|
-
# @return [String] serialized object
|
31
|
-
#
|
32
|
-
# See Packer#initialize for supported options.
|
33
|
-
#
|
34
|
-
def dump(obj, options=nil)
|
35
|
-
end
|
36
|
-
alias pack dump
|
37
|
-
|
38
|
-
#
|
39
|
-
# Creates a MessagePack::Unpacker instance, which has ext types already registered.
|
40
|
-
# Options are passed to MessagePack::Unpacker#initialized.
|
41
|
-
#
|
42
|
-
# See also Unpacker#initialize for options.
|
43
|
-
#
|
44
|
-
def unpacker(*args)
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# Deserializes an object from the string or io and returns it.
|
49
|
-
#
|
50
|
-
# If there're not enough data to deserialize one object, this method raises EOFError.
|
51
|
-
# If data format is invalid, this method raises MessagePack::MalformedFormatError.
|
52
|
-
# If the object nests too deeply, this method raises MessagePack::StackError.
|
53
|
-
#
|
54
|
-
# @param data [String]
|
55
|
-
# @param options [Hash]
|
56
|
-
# @return [Object] deserialized object
|
57
|
-
#
|
58
|
-
# See Unpacker#initialize for supported options.
|
59
|
-
#
|
60
|
-
def load(data, options=nil)
|
61
|
-
end
|
62
|
-
alias unpack load
|
63
|
-
|
64
|
-
#
|
65
|
-
# Register a type and Class to be registered for packer and/or unpacker.
|
66
|
-
# If options are not specified, factory will use :to_msgpack_ext for packer, and
|
67
|
-
# :from_msgpack_ext for unpacker.
|
68
|
-
#
|
69
|
-
# @param type [Fixnum] type id of registered Class (0-127)
|
70
|
-
# @param klass [Class] Class to be associated with type id
|
71
|
-
# @param options [Hash] specify method name or Proc which are used by packer/unpacker
|
72
|
-
# @return nil
|
73
|
-
#
|
74
|
-
# Supported options:
|
75
|
-
#
|
76
|
-
# * *:packer* specify symbol or proc object for packer
|
77
|
-
# * *:unpacker* specify symbol or proc object for unpacker
|
78
|
-
# * *:optimized_symbols_parsing* specify true to use the optimized symbols parsing (not supported on JRuby now)
|
79
|
-
# * *recursive* specify true to receive the packer or unpacker as argument to generate the extension body manually.
|
80
|
-
#
|
81
|
-
def register_type(type, klass, options={})
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# Returns a list of registered types, ordered by type id.
|
86
|
-
#
|
87
|
-
# @param selector [Symbol] specify to list types registered for :packer, :unpacker or :both (default)
|
88
|
-
# @return Array
|
89
|
-
#
|
90
|
-
def registered_types(selector=:both)
|
91
|
-
end
|
92
|
-
|
93
|
-
#
|
94
|
-
# Returns true/false which indicate specified class or type id is registered or not.
|
95
|
-
#
|
96
|
-
# @param klass_or_type [Class or Fixnum] Class or type id (0-127) to be checked
|
97
|
-
# @param selector [Symbol] specify to check for :packer, :unpacker or :both (default)
|
98
|
-
# @return true or false
|
99
|
-
#
|
100
|
-
def type_registered?(klass_or_type, selector=:both)
|
101
|
-
end
|
102
|
-
|
103
|
-
#
|
104
|
-
# Creates a MessagePack::PooledFactory instance of the given size.
|
105
|
-
#
|
106
|
-
# PooledFactory keeps Packer and Unpacker instance in a pool for improved performance.
|
107
|
-
# Note that the size defines how many instances are kept in cache, not the maximum of instances
|
108
|
-
# that can be created. If the pool limit is reached, a new instance is created anyway.
|
109
|
-
#
|
110
|
-
# @param size [Fixnum] specify how many Packer and Unpacker to keep in cache (default 1)
|
111
|
-
# @param options [Hash] Combined options for Packer and Unpacker. See Packer#initialize and Unpacker#initialize
|
112
|
-
# for supported options.
|
113
|
-
def pool(size=1, **options)
|
114
|
-
end
|
115
|
-
|
116
|
-
class Pool
|
117
|
-
#
|
118
|
-
# Deserializes an object from the string or io and returns it.
|
119
|
-
#
|
120
|
-
# If there're not enough data to deserialize one object, this method raises EOFError.
|
121
|
-
# If data format is invalid, this method raises MessagePack::MalformedFormatError.
|
122
|
-
# If the object nests too deeply, this method raises MessagePack::StackError.
|
123
|
-
#
|
124
|
-
# @param data [String]
|
125
|
-
# @return [Object] deserialized object
|
126
|
-
#
|
127
|
-
# See Unpacker#initialize for supported options.
|
128
|
-
#
|
129
|
-
def load(data)
|
130
|
-
end
|
131
|
-
|
132
|
-
#
|
133
|
-
# Serialize the passed value
|
134
|
-
#
|
135
|
-
# If it could not serialize the object, it raises
|
136
|
-
# NoMethodError: undefined method `to_msgpack' for #<the_object>.
|
137
|
-
#
|
138
|
-
# @param obj [Object] object to serialize
|
139
|
-
# @return [String] serialized object
|
140
|
-
#
|
141
|
-
def dump(object)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|