Module: Mongo::Protocol::Serializers::Header Private

Defined in:
build/ruby-driver-v2.19/lib/mongo/protocol/serializers.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

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.

Class Method Summary collapse

Class Method Details

.deserialize(buffer, options = {}) ⇒ Array<Fixnum>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deserializes the header value from the IO stream

Parameters:

  • buffer (String)

    Buffer containing the message header.

  • options (Hash) (defaults to: {})

    This method currently accepts no options.

Returns:

  • (Array<Fixnum>)

    Array consisting of the deserialized length, request id, response id, and op code.



69
70
71
# File 'build/ruby-driver-v2.19/lib/mongo/protocol/serializers.rb', line 69

def self.deserialize(buffer, options = {})
  buffer.get_bytes(16).unpack(HEADER_PACK)
end

.serialize(buffer, value, validating_keys = nil) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Serializes the header value into the buffer

Parameters:

  • buffer (String)

    Buffer to receive the serialized value.

  • value (String)

    Header value to be serialized.

  • validating_keys (true, false) (defaults to: nil)

    Whether keys should be validated when serializing. This option is deprecated and will not be used. It will removed in version 3.0.

Returns:

  • (String)

    Buffer with serialized value.



58
59
60
# File 'build/ruby-driver-v2.19/lib/mongo/protocol/serializers.rb', line 58

def self.serialize(buffer, value, validating_keys = nil)
  buffer.put_bytes(value.pack(HEADER_PACK))
end