module Mongo::Protocol::Serializers::Bytes
MongoDB wire protocol serialization strategy for n bytes.
Writes and fetches bytes from the byte buffer.
Public Class Methods
Source
# File lib/mongo/protocol/serializers.rb, line 450 def self.deserialize(buffer, options = {}) num_bytes = options[:num_bytes] buffer.get_bytes(num_bytes || buffer.length) end
Deserializes bytes from the byte buffer.
@param [ BSON::ByteBuffer ] buffer Buffer containing the value to read. @param [ Hash ] options The method options.
@option options [ Integer ] num_bytes Number of bytes to read.
@return [ String ] The bytes.
@since 2.5.0
Source
# File lib/mongo/protocol/serializers.rb, line 436 def self.serialize(buffer, value, validating_keys = BSON::Config.validating_keys?) buffer.put_bytes(value) end
Writes bytes into the buffer.
@param [ BSON::ByteBuffer ] buffer Buffer to receive the bytes. @param [ String ] value The bytes 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