本站源代码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

64 行
2.1KB

  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. package bsonrw
  7. import (
  8. "go.mongodb.org/mongo-driver/bson/bsontype"
  9. "go.mongodb.org/mongo-driver/bson/primitive"
  10. )
  11. // ArrayReader is implemented by types that allow reading values from a BSON
  12. // array.
  13. type ArrayReader interface {
  14. ReadValue() (ValueReader, error)
  15. }
  16. // DocumentReader is implemented by types that allow reading elements from a
  17. // BSON document.
  18. type DocumentReader interface {
  19. ReadElement() (string, ValueReader, error)
  20. }
  21. // ValueReader is a generic interface used to read values from BSON. This type
  22. // is implemented by several types with different underlying representations of
  23. // BSON, such as a bson.Document, raw BSON bytes, or extended JSON.
  24. type ValueReader interface {
  25. Type() bsontype.Type
  26. Skip() error
  27. ReadArray() (ArrayReader, error)
  28. ReadBinary() (b []byte, btype byte, err error)
  29. ReadBoolean() (bool, error)
  30. ReadDocument() (DocumentReader, error)
  31. ReadCodeWithScope() (code string, dr DocumentReader, err error)
  32. ReadDBPointer() (ns string, oid primitive.ObjectID, err error)
  33. ReadDateTime() (int64, error)
  34. ReadDecimal128() (primitive.Decimal128, error)
  35. ReadDouble() (float64, error)
  36. ReadInt32() (int32, error)
  37. ReadInt64() (int64, error)
  38. ReadJavascript() (code string, err error)
  39. ReadMaxKey() error
  40. ReadMinKey() error
  41. ReadNull() error
  42. ReadObjectID() (primitive.ObjectID, error)
  43. ReadRegex() (pattern, options string, err error)
  44. ReadString() (string, error)
  45. ReadSymbol() (symbol string, err error)
  46. ReadTimestamp() (t, i uint32, err error)
  47. ReadUndefined() error
  48. }
  49. // BytesReader is a generic interface used to read BSON bytes from a
  50. // ValueReader. This imterface is meant to be a superset of ValueReader, so that
  51. // types that implement ValueReader may also implement this interface.
  52. //
  53. // The bytes of the value will be appended to dst.
  54. type BytesReader interface {
  55. ReadValueBytes(dst []byte) (bsontype.Type, []byte, error)
  56. }
上海开阖软件有限公司 沪ICP备12045867号-1