module Mongo::Protocol::Serializers::Header
MongoDB wire protocol serialization strategy for message headers.
Serializes and de-serializes four 32-bit integers consisting of the length of the message, the request id, the response id, and the op code for the operation.
Public Class Methods
Deserializes the header value from the IO stream
@param [ String ] buffer Buffer containing the message header. @param [ Hash ] options This method currently accepts no options.
@return [ Array<Fixnum> ] Array consisting of the deserialized
length, request id, response id, and op code.
# File lib/mongo/protocol/serializers.rb, line 68 def self.deserialize(buffer, options = {}) buffer.get_bytes(16).unpack(HEADER_PACK) end
Serializes the header value into the buffer
@param buffer [ String ] Buffer to receive the serialized value. @param value [ String ] Header value to be serialized. @param [ true, false ] validating_keys Whether keys should be validated when serializing.
This option is deprecated and will not be used. It will removed in version 3.0.
@return [ String ] Buffer with serialized value.
# File lib/mongo/protocol/serializers.rb, line 57 def self.serialize(buffer, value, validating_keys = nil) buffer.put_bytes(value.pack(HEADER_PACK)) end