Module: Mongo::Protocol::Serializers::Byte Private

Defined in:
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 a single byte.

Writes and fetches a single byte from the byte buffer.

Class Method Summary collapse

Class Method Details

.deserialize(buffer, _options = {}) ⇒ 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.

Deserializes a byte from the byte buffer.

Parameters:

  • buffer (BSON::ByteBuffer)

    Buffer containing the value to read.

  • options (Hash)

    This method currently accepts no options.

Returns:

  • (String)

    The byte.

Since:

  • 2.5.0



409
410
411
# File 'lib/mongo/protocol/serializers.rb', line 409

def self.deserialize(buffer, _options = {})
  buffer.get_byte
end

.serialize(buffer, value, _validating_keys = nil) ⇒ BSON::ByteBuffer

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.

Writes a byte into the buffer.

Parameters:

  • buffer (BSON::ByteBuffer)

    Buffer to receive the single byte.

  • value (String)

    The byte to write to the buffer.

  • validating_keys (true, false)

    Whether to validate keys. This option is deprecated and will not be used. It will removed in version 3.0.

Returns:

  • (BSON::ByteBuffer)

    Buffer with serialized value.

Since:

  • 2.5.0



397
398
399
# File 'lib/mongo/protocol/serializers.rb', line 397

def self.serialize(buffer, value, _validating_keys = nil)
  buffer.put_byte(value)
end