| 1 | // Copyright (C) MongoDB, Inc. 2022-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 wiremessage is intended for internal use only. It is made available |
| 8 | // to facilitate use cases that require access to internal MongoDB driver |
| 9 | // functionality and state. The API of this package is not stable and there is |
| 10 | // no backward compatibility guarantee. |
| 11 | // |
| 12 | // WARNING: THIS PACKAGE IS EXPERIMENTAL AND MAY BE MODIFIED OR REMOVED WITHOUT |
| 13 | // NOTICE! USE WITH EXTREME CAUTION! |
| 14 | package wiremessagescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ |
| 15 | |
| 16 | import ( |
| 17 | "bytesscip-go gomod github.com/golang/go/src go1.18 bytes/" |
| 18 | "encoding/binaryscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/" |
| 19 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 20 | "sync/atomicscip-go gomod github.com/golang/go/src go1.18 `sync/atomic`/" |
| 21 | |
| 22 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/" |
| 23 | ) |
| 24 | |
| 25 | // WireMessage represents a MongoDB wire message in binary form. |
| 26 | type WireMessagescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/WireMessage# []byte |
| 27 | |
| 28 | var globalRequestIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/globalRequestID. int32 |
| 29 | |
| 30 | // NextRequestID returns the next request ID. |
| 31 | func NextRequestIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/NextRequestID().() int32 { return atomicscip-go gomod github.com/golang/go/src go1.18 `sync/atomic`/.AddInt32scip-go gomod github.com/golang/go/src go1.18 `sync/atomic`/AddInt32().(&globalRequestIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/globalRequestID., 1) } |
| 32 | |
| 33 | // OpCode represents a MongoDB wire protocol opcode. |
| 34 | type OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# int32 |
| 35 | |
| 36 | // These constants are the valid opcodes for the version of the wireprotocol |
| 37 | // supported by this library. The skipped OpCodes are historical OpCodes that |
| 38 | // are no longer used. |
| 39 | const ( |
| 40 | OpReplyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpReply. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 1 |
| 41 | _ OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 1001 |
| 42 | OpUpdatescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpUpdate. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2001 |
| 43 | OpInsertscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpInsert. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2002 |
| 44 | _ OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2003 |
| 45 | // Deprecated: Use OpMsg instead. |
| 46 | OpQueryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpQuery. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2004 |
| 47 | OpGetMorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpGetMore. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2005 |
| 48 | OpDeletescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpDelete. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2006 |
| 49 | OpKillCursorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpKillCursors. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2007 |
| 50 | OpCommandscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCommand. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2010 |
| 51 | OpCommandReplyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCommandReply. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2011 |
| 52 | OpCompressedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCompressed. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2012 |
| 53 | OpMsgscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpMsg. OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode# = 2013 |
| 54 | ) |
| 55 | |
| 56 | // String implements the fmt.Stringer interface. |
| 57 | func (oc OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#String().() string { |
| 58 | switch oc { |
| 59 | case OpReplyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpReply.: |
| 60 | return "OP_REPLY" |
| 61 | case OpUpdatescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpUpdate.: |
| 62 | return "OP_UPDATE" |
| 63 | case OpInsertscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpInsert.: |
| 64 | return "OP_INSERT" |
| 65 | case OpQueryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpQuery.: |
| 66 | return "OP_QUERY" |
| 67 | case OpGetMorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpGetMore.: |
| 68 | return "OP_GET_MORE" |
| 69 | case OpDeletescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpDelete.: |
| 70 | return "OP_DELETE" |
| 71 | case OpKillCursorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpKillCursors.: |
| 72 | return "OP_KILL_CURSORS" |
| 73 | case OpCommandscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCommand.: |
| 74 | return "OP_COMMAND" |
| 75 | case OpCommandReplyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCommandReply.: |
| 76 | return "OP_COMMANDREPLY" |
| 77 | case OpCompressedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCompressed.: |
| 78 | return "OP_COMPRESSED" |
| 79 | case OpMsgscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpMsg.: |
| 80 | return "OP_MSG" |
| 81 | default: |
| 82 | return "<invalid opcode>" |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // QueryFlag represents the flags on an OP_QUERY message. |
| 87 | type QueryFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFlag# int32 |
| 88 | |
| 89 | // These constants represent the individual flags on an OP_QUERY message. |
| 90 | const ( |
| 91 | _ QueryFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFlag# = 1 << iota |
| 92 | TailableCursorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/TailableCursor. |
| 93 | SecondaryOKscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SecondaryOK. |
| 94 | OplogReplayscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OplogReplay. |
| 95 | NoCursorTimeoutscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/NoCursorTimeout. |
| 96 | AwaitDatascip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AwaitData. |
| 97 | Exhaustscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/Exhaust. |
| 98 | Partialscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/Partial. |
| 99 | ) |
| 100 | |
| 101 | // String implements the fmt.Stringer interface. |
| 102 | func (qf QueryFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFlag#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFlag#String().() string { |
| 103 | strs := make([]string, 0) |
| 104 | if qf&TailableCursorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/TailableCursor. == TailableCursorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/TailableCursor. { |
| 105 | strs = append(strs, "TailableCursor") |
| 106 | } |
| 107 | if qf&SecondaryOKscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SecondaryOK. == SecondaryOKscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SecondaryOK. { |
| 108 | strs = append(strs, "SecondaryOK") |
| 109 | } |
| 110 | if qf&OplogReplayscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OplogReplay. == OplogReplayscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OplogReplay. { |
| 111 | strs = append(strs, "OplogReplay") |
| 112 | } |
| 113 | if qf&NoCursorTimeoutscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/NoCursorTimeout. == NoCursorTimeoutscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/NoCursorTimeout. { |
| 114 | strs = append(strs, "NoCursorTimeout") |
| 115 | } |
| 116 | if qf&AwaitDatascip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AwaitData. == AwaitDatascip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AwaitData. { |
| 117 | strs = append(strs, "AwaitData") |
| 118 | } |
| 119 | if qf&Exhaustscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/Exhaust. == Exhaustscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/Exhaust. { |
| 120 | strs = append(strs, "Exhaust") |
| 121 | } |
| 122 | if qf&Partialscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/Partial. == Partialscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/Partial. { |
| 123 | strs = append(strs, "Partial") |
| 124 | } |
| 125 | str := "[" |
| 126 | str += stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Joinscip-go gomod github.com/golang/go/src go1.18 strings/Join().(strs, ", ") |
| 127 | str += "]" |
| 128 | return str |
| 129 | } |
| 130 | |
| 131 | // MsgFlag represents the flags on an OP_MSG message. |
| 132 | type MsgFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MsgFlag# uint32 |
| 133 | |
| 134 | // These constants represent the individual flags on an OP_MSG message. |
| 135 | const ( |
| 136 | ChecksumPresentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ChecksumPresent. MsgFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MsgFlag# = 1 << iota |
| 137 | MoreToComescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MoreToCome. |
| 138 | |
| 139 | ExhaustAllowedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ExhaustAllowed. MsgFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MsgFlag# = 1 << 16 |
| 140 | ) |
| 141 | |
| 142 | // ReplyFlag represents the flags of an OP_REPLY message. |
| 143 | type ReplyFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReplyFlag# int32 |
| 144 | |
| 145 | // These constants represent the individual flags of an OP_REPLY message. |
| 146 | const ( |
| 147 | CursorNotFoundscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CursorNotFound. ReplyFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReplyFlag# = 1 << iota |
| 148 | QueryFailurescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFailure. |
| 149 | ShardConfigStalescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ShardConfigStale. |
| 150 | AwaitCapablescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AwaitCapable. |
| 151 | ) |
| 152 | |
| 153 | // String implements the fmt.Stringer interface. |
| 154 | func (rf ReplyFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReplyFlag#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReplyFlag#String().() string { |
| 155 | strs := make([]string, 0) |
| 156 | if rf&CursorNotFoundscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CursorNotFound. == CursorNotFoundscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CursorNotFound. { |
| 157 | strs = append(strs, "CursorNotFound") |
| 158 | } |
| 159 | if rf&QueryFailurescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFailure. == QueryFailurescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFailure. { |
| 160 | strs = append(strs, "QueryFailure") |
| 161 | } |
| 162 | if rf&ShardConfigStalescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ShardConfigStale. == ShardConfigStalescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ShardConfigStale. { |
| 163 | strs = append(strs, "ShardConfigStale") |
| 164 | } |
| 165 | if rf&AwaitCapablescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AwaitCapable. == AwaitCapablescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AwaitCapable. { |
| 166 | strs = append(strs, "AwaitCapable") |
| 167 | } |
| 168 | str := "[" |
| 169 | str += stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Joinscip-go gomod github.com/golang/go/src go1.18 strings/Join().(strs, ", ") |
| 170 | str += "]" |
| 171 | return str |
| 172 | } |
| 173 | |
| 174 | // SectionType represents the type for 1 section in an OP_MSG |
| 175 | type SectionTypescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SectionType# uint8 |
| 176 | |
| 177 | // These constants represent the individual section types for a section in an OP_MSG |
| 178 | const ( |
| 179 | SingleDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SingleDocument. SectionTypescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SectionType# = iota |
| 180 | DocumentSequencescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/DocumentSequence. |
| 181 | ) |
| 182 | |
| 183 | // CompressorID is the ID for each type of Compressor. |
| 184 | type CompressorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorID# uint8 |
| 185 | |
| 186 | // These constants represent the individual compressor IDs for an OP_COMPRESSED. |
| 187 | const ( |
| 188 | CompressorNoOpscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorNoOp. CompressorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorID# = iota |
| 189 | CompressorSnappyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorSnappy. |
| 190 | CompressorZLibscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorZLib. |
| 191 | CompressorZstdscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorZstd. |
| 192 | ) |
| 193 | |
| 194 | // String implements the fmt.Stringer interface. |
| 195 | func (id CompressorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorID#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorID#String().() string { |
| 196 | switch id { |
| 197 | case CompressorNoOpscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorNoOp.: |
| 198 | return "CompressorNoOp" |
| 199 | case CompressorSnappyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorSnappy.: |
| 200 | return "CompressorSnappy" |
| 201 | case CompressorZLibscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorZLib.: |
| 202 | return "CompressorZLib" |
| 203 | case CompressorZstdscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorZstd.: |
| 204 | return "CompressorZstd" |
| 205 | default: |
| 206 | return "CompressorInvalid" |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | const ( |
| 211 | // DefaultZlibLevel is the default level for zlib compression |
| 212 | DefaultZlibLevelscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/DefaultZlibLevel. = 6 |
| 213 | // DefaultZstdLevel is the default level for zstd compression. |
| 214 | // Matches https://github.com/wiredtiger/wiredtiger/blob/f08bc4b18612ef95a39b12166abcccf207f91596/ext/compressors/zstd/zstd_compress.c#L299 |
| 215 | DefaultZstdLevelscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/DefaultZstdLevel. = 6 |
| 216 | ) |
| 217 | |
| 218 | // AppendHeaderStart appends a header to the dst slice and returns an index where the wire message |
| 219 | // starts in dst and the updated slice. |
| 220 | func AppendHeaderStartscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendHeaderStart().(dst []byte, reqid, respto int32, opcode OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#) (index int32, b []byte) { |
| 221 | index, dst = bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.ReserveLengthscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/ReserveLength().(dst) |
| 222 | dst = appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, reqid) |
| 223 | dst = appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, respto) |
| 224 | dst = appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, int32(opcode)) |
| 225 | return index, dst |
| 226 | } |
| 227 | |
| 228 | // AppendHeader appends a header to dst. |
| 229 | func AppendHeaderscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendHeader().(dst []byte, length, reqid, respto int32, opcode OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#) []byte { |
| 230 | dst = appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, length) |
| 231 | dst = appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, reqid) |
| 232 | dst = appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, respto) |
| 233 | dst = appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, int32(opcode)) |
| 234 | return dst |
| 235 | } |
| 236 | |
| 237 | // ReadHeader reads a wire message header from src. |
| 238 | func ReadHeaderscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadHeader().(src []byte) (length, requestID, responseTo int32, opcode OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#, rem []byte, ok bool) { |
| 239 | if len(src) < 16 { |
| 240 | return 0, 0, 0, 0, src, false |
| 241 | } |
| 242 | |
| 243 | length = readi32unsafescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32unsafe().(src) |
| 244 | requestID = readi32unsafescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32unsafe().(src[4:]) |
| 245 | responseTo = readi32unsafescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32unsafe().(src[8:]) |
| 246 | opcode = OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#(readi32unsafescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32unsafe().(src[12:])) |
| 247 | return length, requestID, responseTo, opcode, src[16:], true |
| 248 | } |
| 249 | |
| 250 | // AppendQueryFlags appends the flags for an OP_QUERY wire message. |
| 251 | func AppendQueryFlagsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendQueryFlags().(dst []byte, flags QueryFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFlag#) []byte { |
| 252 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, int32(flags)) |
| 253 | } |
| 254 | |
| 255 | // AppendMsgFlags appends the flags for an OP_MSG wire message. |
| 256 | func AppendMsgFlagsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendMsgFlags().(dst []byte, flags MsgFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MsgFlag#) []byte { |
| 257 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, int32(flags)) |
| 258 | } |
| 259 | |
| 260 | // AppendReplyFlags appends the flags for an OP_REPLY wire message. |
| 261 | func AppendReplyFlagsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendReplyFlags().(dst []byte, flags ReplyFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReplyFlag#) []byte { |
| 262 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, int32(flags)) |
| 263 | } |
| 264 | |
| 265 | // AppendMsgSectionType appends the section type to dst. |
| 266 | func AppendMsgSectionTypescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendMsgSectionType().(dst []byte, stype SectionTypescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SectionType#) []byte { |
| 267 | return append(dst, byte(stype)) |
| 268 | } |
| 269 | |
| 270 | // AppendQueryFullCollectionName appends the full collection name to dst. |
| 271 | func AppendQueryFullCollectionNamescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendQueryFullCollectionName().(dst []byte, ns string) []byte { |
| 272 | return appendCStringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendCString().(dst, ns) |
| 273 | } |
| 274 | |
| 275 | // AppendQueryNumberToSkip appends the number to skip to dst. |
| 276 | func AppendQueryNumberToSkipscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendQueryNumberToSkip().(dst []byte, skip int32) []byte { |
| 277 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, skip) |
| 278 | } |
| 279 | |
| 280 | // AppendQueryNumberToReturn appends the number to return to dst. |
| 281 | func AppendQueryNumberToReturnscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendQueryNumberToReturn().(dst []byte, nor int32) []byte { |
| 282 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, nor) |
| 283 | } |
| 284 | |
| 285 | // AppendReplyCursorID appends the cursor ID to dst. |
| 286 | func AppendReplyCursorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendReplyCursorID().(dst []byte, id int64) []byte { |
| 287 | return appendi64scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi64().(dst, id) |
| 288 | } |
| 289 | |
| 290 | // AppendReplyStartingFrom appends the starting from field to dst. |
| 291 | func AppendReplyStartingFromscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendReplyStartingFrom().(dst []byte, sf int32) []byte { |
| 292 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, sf) |
| 293 | } |
| 294 | |
| 295 | // AppendReplyNumberReturned appends the number returned to dst. |
| 296 | func AppendReplyNumberReturnedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendReplyNumberReturned().(dst []byte, nr int32) []byte { |
| 297 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, nr) |
| 298 | } |
| 299 | |
| 300 | // AppendCompressedOriginalOpCode appends the original opcode to dst. |
| 301 | func AppendCompressedOriginalOpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendCompressedOriginalOpCode().(dst []byte, opcode OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#) []byte { |
| 302 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, int32(opcode)) |
| 303 | } |
| 304 | |
| 305 | // AppendCompressedUncompressedSize appends the uncompressed size of a |
| 306 | // compressed wiremessage to dst. |
| 307 | func AppendCompressedUncompressedSizescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendCompressedUncompressedSize().(dst []byte, size int32) []byte { return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, size) } |
| 308 | |
| 309 | // AppendCompressedCompressorID appends the ID of the compressor to dst. |
| 310 | func AppendCompressedCompressorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendCompressedCompressorID().(dst []byte, id CompressorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorID#) []byte { |
| 311 | return append(dst, byte(id)) |
| 312 | } |
| 313 | |
| 314 | // AppendCompressedCompressedMessage appends the compressed wiremessage to dst. |
| 315 | func AppendCompressedCompressedMessagescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendCompressedCompressedMessage().(dst []byte, msg []byte) []byte { return append(dst, msg...) } |
| 316 | |
| 317 | // AppendGetMoreZero appends the zero field to dst. |
| 318 | func AppendGetMoreZeroscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendGetMoreZero().(dst []byte) []byte { |
| 319 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, 0) |
| 320 | } |
| 321 | |
| 322 | // AppendGetMoreFullCollectionName appends the fullCollectionName field to dst. |
| 323 | func AppendGetMoreFullCollectionNamescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendGetMoreFullCollectionName().(dst []byte, ns string) []byte { |
| 324 | return appendCStringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendCString().(dst, ns) |
| 325 | } |
| 326 | |
| 327 | // AppendGetMoreNumberToReturn appends the numberToReturn field to dst. |
| 328 | func AppendGetMoreNumberToReturnscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendGetMoreNumberToReturn().(dst []byte, numToReturn int32) []byte { |
| 329 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, numToReturn) |
| 330 | } |
| 331 | |
| 332 | // AppendGetMoreCursorID appends the cursorID field to dst. |
| 333 | func AppendGetMoreCursorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendGetMoreCursorID().(dst []byte, cursorID int64) []byte { |
| 334 | return appendi64scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi64().(dst, cursorID) |
| 335 | } |
| 336 | |
| 337 | // AppendKillCursorsZero appends the zero field to dst. |
| 338 | func AppendKillCursorsZeroscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendKillCursorsZero().(dst []byte) []byte { |
| 339 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, 0) |
| 340 | } |
| 341 | |
| 342 | // AppendKillCursorsNumberIDs appends the numberOfCursorIDs field to dst. |
| 343 | func AppendKillCursorsNumberIDsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendKillCursorsNumberIDs().(dst []byte, numIDs int32) []byte { |
| 344 | return appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst, numIDs) |
| 345 | } |
| 346 | |
| 347 | // AppendKillCursorsCursorIDs appends each the cursorIDs field to dst. |
| 348 | func AppendKillCursorsCursorIDsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/AppendKillCursorsCursorIDs().(dst []byte, cursors []int64) []byte { |
| 349 | for _, cursor := range cursors { |
| 350 | dst = appendi64scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi64().(dst, cursor) |
| 351 | } |
| 352 | return dst |
| 353 | } |
| 354 | |
| 355 | // ReadMsgFlags reads the OP_MSG flags from src. |
| 356 | func ReadMsgFlagsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadMsgFlags().(src []byte) (flags MsgFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MsgFlag#, rem []byte, ok bool) { |
| 357 | i32, rem, ok := readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 358 | return MsgFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MsgFlag#(i32), rem, ok |
| 359 | } |
| 360 | |
| 361 | // IsMsgMoreToCome returns if the provided wire message is an OP_MSG with the more to come flag set. |
| 362 | func IsMsgMoreToComescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/IsMsgMoreToCome().(wm []byte) bool { |
| 363 | return len(wm) >= 20 && |
| 364 | OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#(readi32unsafescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32unsafe().(wm[12:16])) == OpMsgscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpMsg. && |
| 365 | MsgFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MsgFlag#(readi32unsafescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32unsafe().(wm[16:20]))&MoreToComescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MoreToCome. == MoreToComescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/MoreToCome. |
| 366 | } |
| 367 | |
| 368 | // ReadMsgSectionType reads the section type from src. |
| 369 | func ReadMsgSectionTypescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadMsgSectionType().(src []byte) (stype SectionTypescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SectionType#, rem []byte, ok bool) { |
| 370 | if len(src) < 1 { |
| 371 | return 0, src, false |
| 372 | } |
| 373 | return SectionTypescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/SectionType#(src[0]), src[1:], true |
| 374 | } |
| 375 | |
| 376 | // ReadMsgSectionSingleDocument reads a single document from src. |
| 377 | func ReadMsgSectionSingleDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadMsgSectionSingleDocument().(src []byte) (doc bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#, rem []byte, ok bool) { |
| 378 | return bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.ReadDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/ReadDocument().(src) |
| 379 | } |
| 380 | |
| 381 | // ReadMsgSectionDocumentSequence reads an identifier and document sequence from src and returns the document sequence |
| 382 | // data parsed into a slice of BSON documents. |
| 383 | func ReadMsgSectionDocumentSequencescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadMsgSectionDocumentSequence().(src []byte) (identifier string, docs []bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#, rem []byte, ok bool) { |
| 384 | identifier, rem, ret, ok := ReadMsgSectionRawDocumentSequencescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadMsgSectionRawDocumentSequence().(src) |
| 385 | if !ok { |
| 386 | return "", nil, src, false |
| 387 | } |
| 388 | |
| 389 | docs = make([]bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#, 0) |
| 390 | var doc bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document# |
| 391 | for { |
| 392 | doc, rem, ok = bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.ReadDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/ReadDocument().(rem) |
| 393 | if !ok { |
| 394 | break |
| 395 | } |
| 396 | docs = append(docs, doc) |
| 397 | } |
| 398 | if len(rem) > 0 { |
| 399 | return "", nil, src, false |
| 400 | } |
| 401 | |
| 402 | return identifier, docs, ret, true |
| 403 | } |
| 404 | |
| 405 | // ReadMsgSectionRawDocumentSequence reads an identifier and document sequence from src and returns the raw document |
| 406 | // sequence data. |
| 407 | func ReadMsgSectionRawDocumentSequencescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadMsgSectionRawDocumentSequence().(src []byte) (identifier string, data []byte, rem []byte, ok bool) { |
| 408 | length, rem, ok := readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 409 | if !ok || int(length) > len(src) || length-4 < 0 { |
| 410 | return "", nil, src, false |
| 411 | } |
| 412 | |
| 413 | // After these assignments, rem will be the data containing the identifier string + the document sequence bytes and |
| 414 | // rest will be the rest of the wire message after this document sequence. |
| 415 | rem, rest := rem[:length-4], rem[length-4:] |
| 416 | |
| 417 | identifier, rem, ok = readcstringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readcstring().(rem) |
| 418 | if !ok { |
| 419 | return "", nil, src, false |
| 420 | } |
| 421 | |
| 422 | return identifier, rem, rest, true |
| 423 | } |
| 424 | |
| 425 | // ReadMsgChecksum reads a checksum from src. |
| 426 | func ReadMsgChecksumscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadMsgChecksum().(src []byte) (checksum uint32, rem []byte, ok bool) { |
| 427 | i32, rem, ok := readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 428 | return uint32(i32), rem, ok |
| 429 | } |
| 430 | |
| 431 | // ReadQueryFlags reads OP_QUERY flags from src. |
| 432 | // |
| 433 | // Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions |
| 434 | // instead. |
| 435 | func ReadQueryFlagsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadQueryFlags().(src []byte) (flags QueryFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFlag#, rem []byte, ok bool) { |
| 436 | i32, rem, ok := readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 437 | return QueryFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/QueryFlag#(i32), rem, ok |
| 438 | } |
| 439 | |
| 440 | // ReadQueryFullCollectionName reads the full collection name from src. |
| 441 | // |
| 442 | // Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions |
| 443 | // instead. |
| 444 | func ReadQueryFullCollectionNamescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadQueryFullCollectionName().(src []byte) (collname string, rem []byte, ok bool) { |
| 445 | return readcstringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readcstring().(src) |
| 446 | } |
| 447 | |
| 448 | // ReadQueryNumberToSkip reads the number to skip from src. |
| 449 | // |
| 450 | // Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions |
| 451 | // instead. |
| 452 | func ReadQueryNumberToSkipscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadQueryNumberToSkip().(src []byte) (nts int32, rem []byte, ok bool) { |
| 453 | return readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 454 | } |
| 455 | |
| 456 | // ReadQueryNumberToReturn reads the number to return from src. |
| 457 | // |
| 458 | // Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions |
| 459 | // instead. |
| 460 | func ReadQueryNumberToReturnscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadQueryNumberToReturn().(src []byte) (ntr int32, rem []byte, ok bool) { |
| 461 | return readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 462 | } |
| 463 | |
| 464 | // ReadQueryQuery reads the query from src. |
| 465 | // |
| 466 | // Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions |
| 467 | // instead. |
| 468 | func ReadQueryQueryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadQueryQuery().(src []byte) (query bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#, rem []byte, ok bool) { |
| 469 | return bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.ReadDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/ReadDocument().(src) |
| 470 | } |
| 471 | |
| 472 | // ReadQueryReturnFieldsSelector reads a return fields selector document from src. |
| 473 | // |
| 474 | // Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions |
| 475 | // instead. |
| 476 | func ReadQueryReturnFieldsSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadQueryReturnFieldsSelector().(src []byte) (rfs bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#, rem []byte, ok bool) { |
| 477 | return bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.ReadDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/ReadDocument().(src) |
| 478 | } |
| 479 | |
| 480 | // ReadReplyFlags reads OP_REPLY flags from src. |
| 481 | func ReadReplyFlagsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadReplyFlags().(src []byte) (flags ReplyFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReplyFlag#, rem []byte, ok bool) { |
| 482 | i32, rem, ok := readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 483 | return ReplyFlagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReplyFlag#(i32), rem, ok |
| 484 | } |
| 485 | |
| 486 | // ReadReplyCursorID reads a cursor ID from src. |
| 487 | func ReadReplyCursorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadReplyCursorID().(src []byte) (cursorID int64, rem []byte, ok bool) { |
| 488 | return readi64scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi64().(src) |
| 489 | } |
| 490 | |
| 491 | // ReadReplyStartingFrom reads the starting from src. |
| 492 | func ReadReplyStartingFromscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadReplyStartingFrom().(src []byte) (startingFrom int32, rem []byte, ok bool) { |
| 493 | return readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 494 | } |
| 495 | |
| 496 | // ReadReplyNumberReturned reads the numbered returned from src. |
| 497 | func ReadReplyNumberReturnedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadReplyNumberReturned().(src []byte) (numberReturned int32, rem []byte, ok bool) { |
| 498 | return readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 499 | } |
| 500 | |
| 501 | // ReadReplyDocuments reads as many documents as possible from src |
| 502 | func ReadReplyDocumentsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadReplyDocuments().(src []byte) (docs []bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#, rem []byte, ok bool) { |
| 503 | rem = src |
| 504 | for { |
| 505 | var doc bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document# |
| 506 | doc, rem, ok = bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.ReadDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/ReadDocument().(rem) |
| 507 | if !ok { |
| 508 | break |
| 509 | } |
| 510 | |
| 511 | docs = append(docs, doc) |
| 512 | } |
| 513 | |
| 514 | return docs, rem, true |
| 515 | } |
| 516 | |
| 517 | // ReadReplyDocument reads a reply document from src. |
| 518 | func ReadReplyDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadReplyDocument().(src []byte) (doc bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.Documentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/Document#, rem []byte, ok bool) { |
| 519 | return bsoncorescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/.ReadDocumentscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/bsonx/bsoncore`/ReadDocument().(src) |
| 520 | } |
| 521 | |
| 522 | // ReadCompressedOriginalOpCode reads the original opcode from src. |
| 523 | func ReadCompressedOriginalOpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadCompressedOriginalOpCode().(src []byte) (opcode OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#, rem []byte, ok bool) { |
| 524 | i32, rem, ok := readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 525 | return OpCodescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/OpCode#(i32), rem, ok |
| 526 | } |
| 527 | |
| 528 | // ReadCompressedUncompressedSize reads the uncompressed size of a |
| 529 | // compressed wiremessage to dst. |
| 530 | func ReadCompressedUncompressedSizescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadCompressedUncompressedSize().(src []byte) (size int32, rem []byte, ok bool) { |
| 531 | return readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 532 | } |
| 533 | |
| 534 | // ReadCompressedCompressorID reads the ID of the compressor to dst. |
| 535 | func ReadCompressedCompressorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadCompressedCompressorID().(src []byte) (id CompressorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorID#, rem []byte, ok bool) { |
| 536 | if len(src) < 1 { |
| 537 | return 0, src, false |
| 538 | } |
| 539 | return CompressorIDscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/CompressorID#(src[0]), src[1:], true |
| 540 | } |
| 541 | |
| 542 | // ReadCompressedCompressedMessage reads the compressed wiremessage to dst. |
| 543 | // |
| 544 | // Deprecated: This function is not required by the Go Driver and will be |
| 545 | // removed in the 2.0 release. |
| 546 | func ReadCompressedCompressedMessagescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadCompressedCompressedMessage().(src []byte, length int32) (msg []byte, rem []byte, ok bool) { |
| 547 | if len(src) < int(length) || length < 0 { |
| 548 | return nil, src, false |
| 549 | } |
| 550 | return src[:length], src[length:], true |
| 551 | } |
| 552 | |
| 553 | // ReadKillCursorsZero reads the zero field from src. |
| 554 | func ReadKillCursorsZeroscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadKillCursorsZero().(src []byte) (zero int32, rem []byte, ok bool) { |
| 555 | return readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 556 | } |
| 557 | |
| 558 | // ReadKillCursorsNumberIDs reads the numberOfCursorIDs field from src. |
| 559 | func ReadKillCursorsNumberIDsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadKillCursorsNumberIDs().(src []byte) (numIDs int32, rem []byte, ok bool) { |
| 560 | return readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src) |
| 561 | } |
| 562 | |
| 563 | // ReadKillCursorsCursorIDs reads numIDs cursor IDs from src. |
| 564 | func ReadKillCursorsCursorIDsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/ReadKillCursorsCursorIDs().(src []byte, numIDs int32) (cursorIDs []int64, rem []byte, ok bool) { |
| 565 | var i int32 |
| 566 | var id int64 |
| 567 | for i = 0; i < numIDs; i++ { |
| 568 | id, src, ok = readi64scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi64().(src) |
| 569 | if !ok { |
| 570 | return cursorIDs, src, false |
| 571 | } |
| 572 | |
| 573 | cursorIDs = append(cursorIDs, id) |
| 574 | } |
| 575 | return cursorIDs, src, true |
| 576 | } |
| 577 | |
| 578 | func appendi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi32().(dst []byte, x int32) []byte { |
| 579 | b := []byte{0, 0, 0, 0} |
| 580 | binaryscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/LittleEndian..PutUint32scip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/littleEndian#PutUint32().(b, uint32(x)) |
| 581 | return append(dst, b...) |
| 582 | } |
| 583 | |
| 584 | func appendi64scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendi64().(dst []byte, x int64) []byte { |
| 585 | b := []byte{0, 0, 0, 0, 0, 0, 0, 0} |
| 586 | binaryscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/LittleEndian..PutUint64scip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/littleEndian#PutUint64().(b, uint64(x)) |
| 587 | return append(dst, b...) |
| 588 | } |
| 589 | |
| 590 | func appendCStringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/appendCString().(b []byte, str string) []byte { |
| 591 | b = append(b, str...) |
| 592 | return append(b, 0x00) |
| 593 | } |
| 594 | |
| 595 | func readi32scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32().(src []byte) (int32, []byte, bool) { |
| 596 | if len(src) < 4 { |
| 597 | return 0, src, false |
| 598 | } |
| 599 | return readi32unsafescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32unsafe().(src), src[4:], true |
| 600 | } |
| 601 | |
| 602 | func readi32unsafescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi32unsafe().(src []byte) int32 { |
| 603 | return int32(binaryscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/LittleEndian..Uint32scip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/littleEndian#Uint32().(src)) |
| 604 | } |
| 605 | |
| 606 | func readi64scip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readi64().(src []byte) (int64, []byte, bool) { |
| 607 | if len(src) < 8 { |
| 608 | return 0, src, false |
| 609 | } |
| 610 | return int64(binaryscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/.LittleEndianscip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/LittleEndian..Uint64scip-go gomod github.com/golang/go/src go1.18 `encoding/binary`/littleEndian#Uint64().(src)), src[8:], true |
| 611 | } |
| 612 | |
| 613 | func readcstringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage`/readcstring().(src []byte) (string, []byte, bool) { |
| 614 | idx := bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.IndexBytescip-go gomod github.com/golang/go/src go1.18 bytes/IndexByte().(src, 0x00) |
| 615 | if idx < 0 { |
| 616 | return "", src, false |
| 617 | } |
| 618 | return string(src[:idx]), src[idx+1:], true |
| 619 | } |