module Mongo::Protocol::Serializers::Byte

MongoDB wire protocol serialization strategy for a single byte.

Writes and fetches a single byte from the byte buffer.

Public Class Methods

deserialize(buffer, options = {}) click to toggle source

Deserializes a byte from the byte buffer.

@param [ BSON::ByteBuffer ] buffer Buffer containing the value to read. @param [ Hash ] options This method currently accepts no options.

@return [ String ] The byte.

@since 2.5.0

# File lib/mongo/protocol/serializers.rb, line 420
def self.deserialize(buffer, options = {})
  buffer.get_byte
end
serialize(buffer, value, validating_keys = BSON::Config.validating_keys?) click to toggle source

Writes a byte into the buffer.

@param [ BSON::ByteBuffer ] buffer Buffer to receive the single byte. @param [ String ] value The byte to write to the buffer. @param [ true, false ] validating_keys Whether to validate keys.

@return [ BSON::ByteBuffer ] Buffer with serialized value.

@since 2.5.0

# File lib/mongo/protocol/serializers.rb, line 408
def self.serialize(buffer, value, validating_keys = BSON::Config.validating_keys?)
  buffer.put_byte(value)
end