lib/mongo/crypt/context/context.rb
# Runs the mongocrypt_ctx_t state machine and handles
# all I/O on behalf of libmongocrypt
#
# @return [ String|nil ] A BSON string representing the outcome
#   of the state machine. This string could represent different
#   values depending on how the context was initialized.
#
# @raise [ Error::CryptError ] If the state machine enters the
#   :error state
#
# This method is not currently unit tested. It is integration tested
# in spec/integration/explicit_encryption_spec.rb
Runs the mongocrypt_ctx_t state machine and handles
all I/O on behalf of libmongocrypt
Runs the mongocrypt_ctx_t state machine and handles all I / O on behalf of libmongocrypt
def run_state_machine
        while true
          case state
          when :error
            raise_from_status
          when :ready
            return finalize_state_machine
          when :done
            return nil
          when :need_mongo_keys
            filter = Hash.from_bson(BSON::ByteBuffer.new(mongo_operation))
            @encryption_io.find_keys(filter).each do |key|
              mongo_feed(key.to_bson.to_s) if key
            end
            Binding.mongocrypt_ctx_mongo_done(@ctx)
          else
             None of these are required for explicit encryption/decryption,
             so these parts of the state machine will be implemented
             later
            raise("State {state} is not yet supported by Mongo::Crypt::Context")
          end
        end
      end
def run_state_machine while true case state when :error raise_from_status when :ready return finalize_state_machine when :done return nil when :need_mongo_keys filter = Hash . from_bson ( BSON :: ByteBuffer . new ( mongo_operation ) ) @encryption_io . find_keys ( filter ) . each do | key | mongo_feed ( key . to_bson . to_s ) if key end Binding . mongocrypt_ctx_mongo_done ( @ctx ) else raise ( "State #{state} is not yet supported by Mongo::Crypt::Context" ) end end end
Runs the mongocrypt_ctx_t state machine and handles
all I/O on behalf of libmongocrypt
Runs the mongocrypt_ctx_t state machine and handles all I / O on behalf of libmongocrypt
# There are three other states to handle: # - :need_mongo_collinfo # - :need_mongo_markings # - :need_kms # # None of these are required for explicit encryption/decryption, # so these parts of the state machine will be implemented # later
A BSON string representing the outcome of the state machine. This string could represent different values depending on how the context was initialized.
A BSON string representing the outcome of the state machine . This string could represent different values depending on how the context was initialized .
 String|nil 
[ Error::CryptError ] If the state machine enters the :error state This method is not currently unit tested. It is integration tested in spec/integration/explicit_encryption_spec.rb
[ Error :: CryptError ] If the state machine enters the : error state This method is not currently unit tested . It is integration tested in spec / integration / explicit_encryption_spec . rb