github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/go.mongodb.org/mongo-driver/bson/bsonrw/reader.go (about)

     1  // Copyright (C) MongoDB, Inc. 2017-present.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  
     7  package bsonrw
     8  
     9  import (
    10  	"go.mongodb.org/mongo-driver/bson/bsontype"
    11  	"go.mongodb.org/mongo-driver/bson/primitive"
    12  )
    13  
    14  // ArrayReader is implemented by types that allow reading values from a BSON
    15  // array.
    16  type ArrayReader interface {
    17  	ReadValue() (ValueReader, error)
    18  }
    19  
    20  // DocumentReader is implemented by types that allow reading elements from a
    21  // BSON document.
    22  type DocumentReader interface {
    23  	ReadElement() (string, ValueReader, error)
    24  }
    25  
    26  // ValueReader is a generic interface used to read values from BSON. This type
    27  // is implemented by several types with different underlying representations of
    28  // BSON, such as a bson.Document, raw BSON bytes, or extended JSON.
    29  type ValueReader interface {
    30  	Type() bsontype.Type
    31  	Skip() error
    32  
    33  	ReadArray() (ArrayReader, error)
    34  	ReadBinary() (b []byte, btype byte, err error)
    35  	ReadBoolean() (bool, error)
    36  	ReadDocument() (DocumentReader, error)
    37  	ReadCodeWithScope() (code string, dr DocumentReader, err error)
    38  	ReadDBPointer() (ns string, oid primitive.ObjectID, err error)
    39  	ReadDateTime() (int64, error)
    40  	ReadDecimal128() (primitive.Decimal128, error)
    41  	ReadDouble() (float64, error)
    42  	ReadInt32() (int32, error)
    43  	ReadInt64() (int64, error)
    44  	ReadJavascript() (code string, err error)
    45  	ReadMaxKey() error
    46  	ReadMinKey() error
    47  	ReadNull() error
    48  	ReadObjectID() (primitive.ObjectID, error)
    49  	ReadRegex() (pattern, options string, err error)
    50  	ReadString() (string, error)
    51  	ReadSymbol() (symbol string, err error)
    52  	ReadTimestamp() (t, i uint32, err error)
    53  	ReadUndefined() error
    54  }
    55  
    56  // BytesReader is a generic interface used to read BSON bytes from a
    57  // ValueReader. This imterface is meant to be a superset of ValueReader, so that
    58  // types that implement ValueReader may also implement this interface.
    59  //
    60  // The bytes of the value will be appended to dst.
    61  //
    62  // Deprecated: BytesReader will not be supported in Go Driver 2.0.
    63  type BytesReader interface {
    64  	ReadValueBytes(dst []byte) (bsontype.Type, []byte, error)
    65  }