mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
[Vendor] update go-swagger v0.21.0 -> v0.25.0 (#12670)
* Update go-swagger * vendor
This commit is contained in:
89
vendor/go.mongodb.org/mongo-driver/bson/marshal.go
generated
vendored
89
vendor/go.mongodb.org/mongo-driver/bson/marshal.go
generated
vendored
@@ -32,7 +32,8 @@ type ValueMarshaler interface {
|
||||
MarshalBSONValue() (bsontype.Type, []byte, error)
|
||||
}
|
||||
|
||||
// Marshal returns the BSON encoding of val.
|
||||
// Marshal returns the BSON encoding of val as a BSON document. If val is not a type that can be transformed into a
|
||||
// document, MarshalValue should be used instead.
|
||||
//
|
||||
// Marshal will use the default registry created by NewRegistry to recursively
|
||||
// marshal val into a []byte. Marshal will inspect struct tags and alter the
|
||||
@@ -41,34 +42,37 @@ func Marshal(val interface{}) ([]byte, error) {
|
||||
return MarshalWithRegistry(DefaultRegistry, val)
|
||||
}
|
||||
|
||||
// MarshalAppend will append the BSON encoding of val to dst. If dst is not
|
||||
// large enough to hold the BSON encoding of val, dst will be grown.
|
||||
// MarshalAppend will encode val as a BSON document and append the bytes to dst. If dst is not large enough to hold the
|
||||
// bytes, it will be grown. If val is not a type that can be transformed into a document, MarshalValueAppend should be
|
||||
// used instead.
|
||||
func MarshalAppend(dst []byte, val interface{}) ([]byte, error) {
|
||||
return MarshalAppendWithRegistry(DefaultRegistry, dst, val)
|
||||
}
|
||||
|
||||
// MarshalWithRegistry returns the BSON encoding of val using Registry r.
|
||||
// MarshalWithRegistry returns the BSON encoding of val as a BSON document. If val is not a type that can be transformed
|
||||
// into a document, MarshalValueWithRegistry should be used instead.
|
||||
func MarshalWithRegistry(r *bsoncodec.Registry, val interface{}) ([]byte, error) {
|
||||
dst := make([]byte, 0, 256) // TODO: make the default cap a constant
|
||||
return MarshalAppendWithRegistry(r, dst, val)
|
||||
}
|
||||
|
||||
// MarshalWithContext returns the BSON encoding of val using EncodeContext ec.
|
||||
// MarshalWithContext returns the BSON encoding of val as a BSON document using EncodeContext ec. If val is not a type
|
||||
// that can be transformed into a document, MarshalValueWithContext should be used instead.
|
||||
func MarshalWithContext(ec bsoncodec.EncodeContext, val interface{}) ([]byte, error) {
|
||||
dst := make([]byte, 0, 256) // TODO: make the default cap a constant
|
||||
return MarshalAppendWithContext(ec, dst, val)
|
||||
}
|
||||
|
||||
// MarshalAppendWithRegistry will append the BSON encoding of val to dst using
|
||||
// Registry r. If dst is not large enough to hold the BSON encoding of val, dst
|
||||
// will be grown.
|
||||
// MarshalAppendWithRegistry will encode val as a BSON document using Registry r and append the bytes to dst. If dst is
|
||||
// not large enough to hold the bytes, it will be grown. If val is not a type that can be transformed into a document,
|
||||
// MarshalValueAppendWithRegistry should be used instead.
|
||||
func MarshalAppendWithRegistry(r *bsoncodec.Registry, dst []byte, val interface{}) ([]byte, error) {
|
||||
return MarshalAppendWithContext(bsoncodec.EncodeContext{Registry: r}, dst, val)
|
||||
}
|
||||
|
||||
// MarshalAppendWithContext will append the BSON encoding of val to dst using
|
||||
// EncodeContext ec. If dst is not large enough to hold the BSON encoding of val, dst
|
||||
// will be grown.
|
||||
// MarshalAppendWithContext will encode val as a BSON document using Registry r and EncodeContext ec and append the
|
||||
// bytes to dst. If dst is not large enough to hold the bytes, it will be grown. If val is not a type that can be
|
||||
// transformed into a document, MarshalValueAppendWithContext should be used instead.
|
||||
func MarshalAppendWithContext(ec bsoncodec.EncodeContext, dst []byte, val interface{}) ([]byte, error) {
|
||||
sw := new(bsonrw.SliceWriter)
|
||||
*sw = dst
|
||||
@@ -95,6 +99,69 @@ func MarshalAppendWithContext(ec bsoncodec.EncodeContext, dst []byte, val interf
|
||||
return *sw, nil
|
||||
}
|
||||
|
||||
// MarshalValue returns the BSON encoding of val.
|
||||
//
|
||||
// MarshalValue will use bson.DefaultRegistry to transform val into a BSON value. If val is a struct, this function will
|
||||
// inspect struct tags and alter the marshalling process accordingly.
|
||||
func MarshalValue(val interface{}) (bsontype.Type, []byte, error) {
|
||||
return MarshalValueWithRegistry(DefaultRegistry, val)
|
||||
}
|
||||
|
||||
// MarshalValueAppend will append the BSON encoding of val to dst. If dst is not large enough to hold the BSON encoding
|
||||
// of val, dst will be grown.
|
||||
func MarshalValueAppend(dst []byte, val interface{}) (bsontype.Type, []byte, error) {
|
||||
return MarshalValueAppendWithRegistry(DefaultRegistry, dst, val)
|
||||
}
|
||||
|
||||
// MarshalValueWithRegistry returns the BSON encoding of val using Registry r.
|
||||
func MarshalValueWithRegistry(r *bsoncodec.Registry, val interface{}) (bsontype.Type, []byte, error) {
|
||||
dst := make([]byte, 0, defaultDstCap)
|
||||
return MarshalValueAppendWithRegistry(r, dst, val)
|
||||
}
|
||||
|
||||
// MarshalValueWithContext returns the BSON encoding of val using EncodeContext ec.
|
||||
func MarshalValueWithContext(ec bsoncodec.EncodeContext, val interface{}) (bsontype.Type, []byte, error) {
|
||||
dst := make([]byte, 0, defaultDstCap)
|
||||
return MarshalValueAppendWithContext(ec, dst, val)
|
||||
}
|
||||
|
||||
// MarshalValueAppendWithRegistry will append the BSON encoding of val to dst using Registry r. If dst is not large
|
||||
// enough to hold the BSON encoding of val, dst will be grown.
|
||||
func MarshalValueAppendWithRegistry(r *bsoncodec.Registry, dst []byte, val interface{}) (bsontype.Type, []byte, error) {
|
||||
return MarshalValueAppendWithContext(bsoncodec.EncodeContext{Registry: r}, dst, val)
|
||||
}
|
||||
|
||||
// MarshalValueAppendWithContext will append the BSON encoding of val to dst using EncodeContext ec. If dst is not large
|
||||
// enough to hold the BSON encoding of val, dst will be grown.
|
||||
func MarshalValueAppendWithContext(ec bsoncodec.EncodeContext, dst []byte, val interface{}) (bsontype.Type, []byte, error) {
|
||||
// get a ValueWriter configured to write to dst
|
||||
sw := new(bsonrw.SliceWriter)
|
||||
*sw = dst
|
||||
vwFlusher := bvwPool.GetAtModeElement(sw)
|
||||
|
||||
// get an Encoder and encode the value
|
||||
enc := encPool.Get().(*Encoder)
|
||||
defer encPool.Put(enc)
|
||||
if err := enc.Reset(vwFlusher); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
if err := enc.SetContext(ec); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
if err := enc.Encode(val); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
// flush the bytes written because we cannot guarantee that a full document has been written
|
||||
// after the flush, *sw will be in the format
|
||||
// [value type, 0 (null byte to indicate end of empty element name), value bytes..]
|
||||
if err := vwFlusher.Flush(); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
buffer := *sw
|
||||
return bsontype.Type(buffer[0]), buffer[2:], nil
|
||||
}
|
||||
|
||||
// MarshalExtJSON returns the extended JSON encoding of val.
|
||||
func MarshalExtJSON(val interface{}, canonical, escapeHTML bool) ([]byte, error) {
|
||||
return MarshalExtJSONWithRegistry(DefaultRegistry, val, canonical, escapeHTML)
|
||||
|
Reference in New Issue
Block a user