1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
module MessagePack
#
# MessagePack::Factory is a class to generate Packer and Unpacker which has
# same set of ext types.
#
class Factory
#
# Creates a MessagePack::Factory instance
#
def initialize
end
#
# Creates a MessagePack::Packer instance, which has ext types already registered.
# Options are passed to MessagePack::Packer#initialized.
#
# See also Packer#initialize for options.
#
def packer(*args)
end
#
# Serialize the passed value
#
# If it could not serialize the object, it raises
# NoMethodError: undefined method `to_msgpack' for #<the_object>.
#
# @param obj [Object] object to serialize
# @param options [Hash]
# @return [String] serialized object
#
# See Packer#initialize for supported options.
#
def dump(obj, options=nil)
end
alias pack dump
#
# Creates a MessagePack::Unpacker instance, which has ext types already registered.
# Options are passed to MessagePack::Unpacker#initialized.
#
# See also Unpacker#initialize for options.
#
def unpacker(*args)
end
#
# Deserializes an object from the string or io and returns it.
#
# If there're not enough data to deserialize one object, this method raises EOFError.
# If data format is invalid, this method raises MessagePack::MalformedFormatError.
# If the object nests too deeply, this method raises MessagePack::StackError.
#
# @param data [String]
# @param options [Hash]
# @return [Object] deserialized object
#
# See Unpacker#initialize for supported options.
#
def load(data, options=nil)
end
alias unpack load
#
# Register a type and Class to be registered for packer and/or unpacker.
# If options are not specified, factory will use :to_msgpack_ext for packer, and
# :from_msgpack_ext for unpacker.
#
# @param type [Fixnum] type id of registered Class (0-127)
# @param klass [Class] Class to be associated with type id
# @param options [Hash] specify method name or Proc which are used by packer/unpacker
# @return nil
#
# Supported options:
#
# * *:packer* specify symbol or proc object for packer
# * *:unpacker* specify symbol or proc object for unpacker
# * *:optimized_symbols_parsing* specify true to use the optimized symbols parsing (not supported on JRuby now)
# * *recursive* specify true to receive the packer or unpacker as argument to generate the extension body manually.
#
def register_type(type, klass, options={})
end
#
# Returns a list of registered types, ordered by type id.
#
# @param selector [Symbol] specify to list types registered for :packer, :unpacker or :both (default)
# @return Array
#
def registered_types(selector=:both)
end
#
# Returns true/false which indicate specified class or type id is registered or not.
#
# @param klass_or_type [Class or Fixnum] Class or type id (0-127) to be checked
# @param selector [Symbol] specify to check for :packer, :unpacker or :both (default)
# @return true or false
#
def type_registered?(klass_or_type, selector=:both)
end
#
# Creates a MessagePack::PooledFactory instance of the given size.
#
# PooledFactory keeps Packer and Unpacker instance in a pool for improved performance.
# Note that the size defines how many instances are kept in cache, not the maximum of instances
# that can be created. If the pool limit is reached, a new instance is created anyway.
#
# @param size [Fixnum] specify how many Packer and Unpacker to keep in cache (default 1)
# @param options [Hash] Combined options for Packer and Unpacker. See Packer#initialize and Unpacker#initialize
# for supported options.
def pool(size=1, **options)
end
class Pool
#
# Deserializes an object from the string or io and returns it.
#
# If there're not enough data to deserialize one object, this method raises EOFError.
# If data format is invalid, this method raises MessagePack::MalformedFormatError.
# If the object nests too deeply, this method raises MessagePack::StackError.
#
# @param data [String]
# @return [Object] deserialized object
#
def load(data)
end
#
# Serialize the passed value
#
# If it could not serialize the object, it raises
# NoMethodError: undefined method `to_msgpack' for #<the_object>.
#
# @param obj [Object] object to serialize
# @return [String] serialized object
#
def dump(object)
end
#
# Yields an Unpacker from the pool, and check it back in.
#
# The unpacker should no longer be held after the block has returned.
#
# @yieldparam unpacker [MessagePack::Unpacker]
# @returns [Object] the block return value
#
def unpacker(&block)
end
#
# Yields a Packer from the pool, and check it back in.
#
# The packer should no longer be held after the block has returned.
#
# @yieldparam packer [MessagePack::Packer]
# @returns [Object] the block return value
#
def packer(&block)
end
end
end
end
|