|
| 1 | +/*eslint-disable*/ |
| 2 | +"use strict"; |
| 3 | + |
| 4 | +var $protobuf = require("protobufjs/minimal"); |
| 5 | + |
| 6 | +// Common aliases |
| 7 | +var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; |
| 8 | + |
| 9 | +// Exported root namespace |
| 10 | +var $root = $protobuf.roots["libp2p-fetch"] || ($protobuf.roots["libp2p-fetch"] = {}); |
| 11 | + |
| 12 | +$root.FetchRequest = (function() { |
| 13 | + |
| 14 | + /** |
| 15 | + * Properties of a FetchRequest. |
| 16 | + * @exports IFetchRequest |
| 17 | + * @interface IFetchRequest |
| 18 | + * @property {string|null} [identifier] FetchRequest identifier |
| 19 | + */ |
| 20 | + |
| 21 | + /** |
| 22 | + * Constructs a new FetchRequest. |
| 23 | + * @exports FetchRequest |
| 24 | + * @classdesc Represents a FetchRequest. |
| 25 | + * @implements IFetchRequest |
| 26 | + * @constructor |
| 27 | + * @param {IFetchRequest=} [p] Properties to set |
| 28 | + */ |
| 29 | + function FetchRequest(p) { |
| 30 | + if (p) |
| 31 | + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) |
| 32 | + if (p[ks[i]] != null) |
| 33 | + this[ks[i]] = p[ks[i]]; |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * FetchRequest identifier. |
| 38 | + * @member {string} identifier |
| 39 | + * @memberof FetchRequest |
| 40 | + * @instance |
| 41 | + */ |
| 42 | + FetchRequest.prototype.identifier = ""; |
| 43 | + |
| 44 | + /** |
| 45 | + * Encodes the specified FetchRequest message. Does not implicitly {@link FetchRequest.verify|verify} messages. |
| 46 | + * @function encode |
| 47 | + * @memberof FetchRequest |
| 48 | + * @static |
| 49 | + * @param {IFetchRequest} m FetchRequest message or plain object to encode |
| 50 | + * @param {$protobuf.Writer} [w] Writer to encode to |
| 51 | + * @returns {$protobuf.Writer} Writer |
| 52 | + */ |
| 53 | + FetchRequest.encode = function encode(m, w) { |
| 54 | + if (!w) |
| 55 | + w = $Writer.create(); |
| 56 | + if (m.identifier != null && Object.hasOwnProperty.call(m, "identifier")) |
| 57 | + w.uint32(10).string(m.identifier); |
| 58 | + return w; |
| 59 | + }; |
| 60 | + |
| 61 | + /** |
| 62 | + * Decodes a FetchRequest message from the specified reader or buffer. |
| 63 | + * @function decode |
| 64 | + * @memberof FetchRequest |
| 65 | + * @static |
| 66 | + * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from |
| 67 | + * @param {number} [l] Message length if known beforehand |
| 68 | + * @returns {FetchRequest} FetchRequest |
| 69 | + * @throws {Error} If the payload is not a reader or valid buffer |
| 70 | + * @throws {$protobuf.util.ProtocolError} If required fields are missing |
| 71 | + */ |
| 72 | + FetchRequest.decode = function decode(r, l) { |
| 73 | + if (!(r instanceof $Reader)) |
| 74 | + r = $Reader.create(r); |
| 75 | + var c = l === undefined ? r.len : r.pos + l, m = new $root.FetchRequest(); |
| 76 | + while (r.pos < c) { |
| 77 | + var t = r.uint32(); |
| 78 | + switch (t >>> 3) { |
| 79 | + case 1: |
| 80 | + m.identifier = r.string(); |
| 81 | + break; |
| 82 | + default: |
| 83 | + r.skipType(t & 7); |
| 84 | + break; |
| 85 | + } |
| 86 | + } |
| 87 | + return m; |
| 88 | + }; |
| 89 | + |
| 90 | + /** |
| 91 | + * Creates a FetchRequest message from a plain object. Also converts values to their respective internal types. |
| 92 | + * @function fromObject |
| 93 | + * @memberof FetchRequest |
| 94 | + * @static |
| 95 | + * @param {Object.<string,*>} d Plain object |
| 96 | + * @returns {FetchRequest} FetchRequest |
| 97 | + */ |
| 98 | + FetchRequest.fromObject = function fromObject(d) { |
| 99 | + if (d instanceof $root.FetchRequest) |
| 100 | + return d; |
| 101 | + var m = new $root.FetchRequest(); |
| 102 | + if (d.identifier != null) { |
| 103 | + m.identifier = String(d.identifier); |
| 104 | + } |
| 105 | + return m; |
| 106 | + }; |
| 107 | + |
| 108 | + /** |
| 109 | + * Creates a plain object from a FetchRequest message. Also converts values to other types if specified. |
| 110 | + * @function toObject |
| 111 | + * @memberof FetchRequest |
| 112 | + * @static |
| 113 | + * @param {FetchRequest} m FetchRequest |
| 114 | + * @param {$protobuf.IConversionOptions} [o] Conversion options |
| 115 | + * @returns {Object.<string,*>} Plain object |
| 116 | + */ |
| 117 | + FetchRequest.toObject = function toObject(m, o) { |
| 118 | + if (!o) |
| 119 | + o = {}; |
| 120 | + var d = {}; |
| 121 | + if (o.defaults) { |
| 122 | + d.identifier = ""; |
| 123 | + } |
| 124 | + if (m.identifier != null && m.hasOwnProperty("identifier")) { |
| 125 | + d.identifier = m.identifier; |
| 126 | + } |
| 127 | + return d; |
| 128 | + }; |
| 129 | + |
| 130 | + /** |
| 131 | + * Converts this FetchRequest to JSON. |
| 132 | + * @function toJSON |
| 133 | + * @memberof FetchRequest |
| 134 | + * @instance |
| 135 | + * @returns {Object.<string,*>} JSON object |
| 136 | + */ |
| 137 | + FetchRequest.prototype.toJSON = function toJSON() { |
| 138 | + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); |
| 139 | + }; |
| 140 | + |
| 141 | + return FetchRequest; |
| 142 | +})(); |
| 143 | + |
| 144 | +$root.FetchResponse = (function() { |
| 145 | + |
| 146 | + /** |
| 147 | + * Properties of a FetchResponse. |
| 148 | + * @exports IFetchResponse |
| 149 | + * @interface IFetchResponse |
| 150 | + * @property {FetchResponse.StatusCode|null} [status] FetchResponse status |
| 151 | + * @property {Uint8Array|null} [data] FetchResponse data |
| 152 | + */ |
| 153 | + |
| 154 | + /** |
| 155 | + * Constructs a new FetchResponse. |
| 156 | + * @exports FetchResponse |
| 157 | + * @classdesc Represents a FetchResponse. |
| 158 | + * @implements IFetchResponse |
| 159 | + * @constructor |
| 160 | + * @param {IFetchResponse=} [p] Properties to set |
| 161 | + */ |
| 162 | + function FetchResponse(p) { |
| 163 | + if (p) |
| 164 | + for (var ks = Object.keys(p), i = 0; i < ks.length; ++i) |
| 165 | + if (p[ks[i]] != null) |
| 166 | + this[ks[i]] = p[ks[i]]; |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * FetchResponse status. |
| 171 | + * @member {FetchResponse.StatusCode} status |
| 172 | + * @memberof FetchResponse |
| 173 | + * @instance |
| 174 | + */ |
| 175 | + FetchResponse.prototype.status = 0; |
| 176 | + |
| 177 | + /** |
| 178 | + * FetchResponse data. |
| 179 | + * @member {Uint8Array} data |
| 180 | + * @memberof FetchResponse |
| 181 | + * @instance |
| 182 | + */ |
| 183 | + FetchResponse.prototype.data = $util.newBuffer([]); |
| 184 | + |
| 185 | + /** |
| 186 | + * Encodes the specified FetchResponse message. Does not implicitly {@link FetchResponse.verify|verify} messages. |
| 187 | + * @function encode |
| 188 | + * @memberof FetchResponse |
| 189 | + * @static |
| 190 | + * @param {IFetchResponse} m FetchResponse message or plain object to encode |
| 191 | + * @param {$protobuf.Writer} [w] Writer to encode to |
| 192 | + * @returns {$protobuf.Writer} Writer |
| 193 | + */ |
| 194 | + FetchResponse.encode = function encode(m, w) { |
| 195 | + if (!w) |
| 196 | + w = $Writer.create(); |
| 197 | + if (m.status != null && Object.hasOwnProperty.call(m, "status")) |
| 198 | + w.uint32(8).int32(m.status); |
| 199 | + if (m.data != null && Object.hasOwnProperty.call(m, "data")) |
| 200 | + w.uint32(18).bytes(m.data); |
| 201 | + return w; |
| 202 | + }; |
| 203 | + |
| 204 | + /** |
| 205 | + * Decodes a FetchResponse message from the specified reader or buffer. |
| 206 | + * @function decode |
| 207 | + * @memberof FetchResponse |
| 208 | + * @static |
| 209 | + * @param {$protobuf.Reader|Uint8Array} r Reader or buffer to decode from |
| 210 | + * @param {number} [l] Message length if known beforehand |
| 211 | + * @returns {FetchResponse} FetchResponse |
| 212 | + * @throws {Error} If the payload is not a reader or valid buffer |
| 213 | + * @throws {$protobuf.util.ProtocolError} If required fields are missing |
| 214 | + */ |
| 215 | + FetchResponse.decode = function decode(r, l) { |
| 216 | + if (!(r instanceof $Reader)) |
| 217 | + r = $Reader.create(r); |
| 218 | + var c = l === undefined ? r.len : r.pos + l, m = new $root.FetchResponse(); |
| 219 | + while (r.pos < c) { |
| 220 | + var t = r.uint32(); |
| 221 | + switch (t >>> 3) { |
| 222 | + case 1: |
| 223 | + m.status = r.int32(); |
| 224 | + break; |
| 225 | + case 2: |
| 226 | + m.data = r.bytes(); |
| 227 | + break; |
| 228 | + default: |
| 229 | + r.skipType(t & 7); |
| 230 | + break; |
| 231 | + } |
| 232 | + } |
| 233 | + return m; |
| 234 | + }; |
| 235 | + |
| 236 | + /** |
| 237 | + * Creates a FetchResponse message from a plain object. Also converts values to their respective internal types. |
| 238 | + * @function fromObject |
| 239 | + * @memberof FetchResponse |
| 240 | + * @static |
| 241 | + * @param {Object.<string,*>} d Plain object |
| 242 | + * @returns {FetchResponse} FetchResponse |
| 243 | + */ |
| 244 | + FetchResponse.fromObject = function fromObject(d) { |
| 245 | + if (d instanceof $root.FetchResponse) |
| 246 | + return d; |
| 247 | + var m = new $root.FetchResponse(); |
| 248 | + switch (d.status) { |
| 249 | + case "OK": |
| 250 | + case 0: |
| 251 | + m.status = 0; |
| 252 | + break; |
| 253 | + case "NOT_FOUND": |
| 254 | + case 1: |
| 255 | + m.status = 1; |
| 256 | + break; |
| 257 | + case "ERROR": |
| 258 | + case 2: |
| 259 | + m.status = 2; |
| 260 | + break; |
| 261 | + } |
| 262 | + if (d.data != null) { |
| 263 | + if (typeof d.data === "string") |
| 264 | + $util.base64.decode(d.data, m.data = $util.newBuffer($util.base64.length(d.data)), 0); |
| 265 | + else if (d.data.length) |
| 266 | + m.data = d.data; |
| 267 | + } |
| 268 | + return m; |
| 269 | + }; |
| 270 | + |
| 271 | + /** |
| 272 | + * Creates a plain object from a FetchResponse message. Also converts values to other types if specified. |
| 273 | + * @function toObject |
| 274 | + * @memberof FetchResponse |
| 275 | + * @static |
| 276 | + * @param {FetchResponse} m FetchResponse |
| 277 | + * @param {$protobuf.IConversionOptions} [o] Conversion options |
| 278 | + * @returns {Object.<string,*>} Plain object |
| 279 | + */ |
| 280 | + FetchResponse.toObject = function toObject(m, o) { |
| 281 | + if (!o) |
| 282 | + o = {}; |
| 283 | + var d = {}; |
| 284 | + if (o.defaults) { |
| 285 | + d.status = o.enums === String ? "OK" : 0; |
| 286 | + if (o.bytes === String) |
| 287 | + d.data = ""; |
| 288 | + else { |
| 289 | + d.data = []; |
| 290 | + if (o.bytes !== Array) |
| 291 | + d.data = $util.newBuffer(d.data); |
| 292 | + } |
| 293 | + } |
| 294 | + if (m.status != null && m.hasOwnProperty("status")) { |
| 295 | + d.status = o.enums === String ? $root.FetchResponse.StatusCode[m.status] : m.status; |
| 296 | + } |
| 297 | + if (m.data != null && m.hasOwnProperty("data")) { |
| 298 | + d.data = o.bytes === String ? $util.base64.encode(m.data, 0, m.data.length) : o.bytes === Array ? Array.prototype.slice.call(m.data) : m.data; |
| 299 | + } |
| 300 | + return d; |
| 301 | + }; |
| 302 | + |
| 303 | + /** |
| 304 | + * Converts this FetchResponse to JSON. |
| 305 | + * @function toJSON |
| 306 | + * @memberof FetchResponse |
| 307 | + * @instance |
| 308 | + * @returns {Object.<string,*>} JSON object |
| 309 | + */ |
| 310 | + FetchResponse.prototype.toJSON = function toJSON() { |
| 311 | + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); |
| 312 | + }; |
| 313 | + |
| 314 | + /** |
| 315 | + * StatusCode enum. |
| 316 | + * @name FetchResponse.StatusCode |
| 317 | + * @enum {number} |
| 318 | + * @property {number} OK=0 OK value |
| 319 | + * @property {number} NOT_FOUND=1 NOT_FOUND value |
| 320 | + * @property {number} ERROR=2 ERROR value |
| 321 | + */ |
| 322 | + FetchResponse.StatusCode = (function() { |
| 323 | + var valuesById = {}, values = Object.create(valuesById); |
| 324 | + values[valuesById[0] = "OK"] = 0; |
| 325 | + values[valuesById[1] = "NOT_FOUND"] = 1; |
| 326 | + values[valuesById[2] = "ERROR"] = 2; |
| 327 | + return values; |
| 328 | + })(); |
| 329 | + |
| 330 | + return FetchResponse; |
| 331 | +})(); |
| 332 | + |
| 333 | +module.exports = $root; |
0 commit comments