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
deserialize(buffer, options = {})
click to toggle source
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 64 def self.deserialize(buffer, options = {}) buffer.get_bytes(16).unpack(HEADER_PACK) end
serialize(buffer, value, validating_keys = BSON::Config.validating_keys?)
click to toggle source
Serializes the header value into the buffer
@param buffer [ String ] Buffer to receive the serialized value. @param value [ String ] Header
value to be serialized.
@return [ String ] Buffer with serialized value.
# File lib/mongo/protocol/serializers.rb, line 53 def self.serialize(buffer, value, validating_keys = BSON::Config.validating_keys?) buffer.put_bytes(value.pack(HEADER_PACK)) end