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) click to toggle source

Deserializes a byte from the byte buffer.

@param [ BSON::ByteBuffer ] buffer Buffer containing the value to read.

@return [ String ] The byte.

@since 2.5.0

# File lib/mongo/protocol/serializers.rb, line 382
def self.deserialize(buffer)
  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 371
def self.serialize(buffer, value, validating_keys = BSON::Config.validating_keys?)
  buffer.put_byte(value)
end