module Mongo::Protocol::Serializers::Sections::PayloadZero
MongoDB wire protocol serialization strategy for a payload 0 type Section of OP_MSG.
@since 2.5.0
Constants
- TYPE
-
The byte identifier for this payload type.
@since 2.5.0
- TYPE_BYTE
-
The byte corresponding to this payload type.
@since 2.5.0
Public Class Methods
Source
# File lib/mongo/protocol/serializers.rb, line 280 def self.deserialize(buffer, options = {}) mode = options[:deserialize_as_bson] ? :bson : nil BSON::Document.from_bson(buffer, **{ mode: mode }) end
Deserializes a section of payload type 0 of an OP_MSG from the IO stream.
@param [ BSON::ByteBuffer ] buffer Buffer containing the sections. @param [ Hash ] options
@option options [ Boolean ] :deserialize_as_bson Whether to perform
section deserialization using BSON types instead of native Ruby types wherever possible.
@return [ Array<BSON::Document> ] Deserialized section.
@since 2.5.0
Source
# File lib/mongo/protocol/serializers.rb, line 263 def self.serialize(buffer, value, max_bson_size = nil, validating_keys = BSON::Config.validating_keys?) buffer.put_byte(TYPE_BYTE) Serializers::Document.serialize(buffer, value, max_bson_size, validating_keys) end
Serializes a section of an OP_MSG, payload type 0.
@param [ BSON::ByteBuffer ] buffer Buffer to receive the serialized Sections
. @param [ BSON::Document, Hash ] value The object to serialize. @param [ Fixnum ] max_bson_size The max bson size of documents in the section. @param [ true, false ] validating_keys Whether to validate document keys.
@return [ BSON::ByteBuffer ] Buffer with serialized value.
@since 2.5.0