module Mongo::Protocol::Serializers::Bytes
MongoDB wire protocol serialization strategy for n bytes.
Writes and fetches bytes from the byte buffer.
Public Class Methods
deserialize(buffer, options = {})
click to toggle source
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
# File lib/mongo/protocol/serializers.rb, line 460 def self.deserialize(buffer, options = {}) num_bytes = options[:num_bytes] buffer.get_bytes(num_bytes || buffer.length) end
serialize(buffer, value, validating_keys = nil)
click to toggle source
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.
This option is deprecated and will not be used. It will removed in version 3.0.
@return [ BSON::ByteBuffer ] Buffer with serialized value.
@since 2.5.0
# File lib/mongo/protocol/serializers.rb, line 446 def self.serialize(buffer, value, validating_keys = nil) buffer.put_bytes(value) end