Skip to content

Instantly share code, notes, and snippets.

@agreatfool
Created February 6, 2018 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agreatfool/97d87bfe2ea6e2d2db209fc278b17ef7 to your computer and use it in GitHub Desktop.
Save agreatfool/97d87bfe2ea6e2d2db209fc278b17ef7 to your computer and use it in GitHub Desktop.
Codes generated by grpc-tools
// package: com.book
// file: book/book.proto
import * as grpc from "grpc";
import * as book_book_pb from "../book/book_pb";
interface IBookServiceService extends grpc.IMethodsMap {
getBook: IGetBook;
getBooksViaAuthor: IGetBooksViaAuthor;
getGreatestBook: IGetGreatestBook;
getBooks: IGetBooks;
}
interface IGetBook {
path: string; // "/com.book.BookService/GetBook"
requestStream: boolean; // false
responseStream: boolean; // false
requestType: book_book_pb.GetBookRequest,
responseType: book_book_pb.Book,
requestSerialize: (arg: book_book_pb.GetBookRequest) => Buffer;
requestDeserialize: (buffer: Uint8Array) => book_book_pb.GetBookRequest;
responseSerialize: (arg: book_book_pb.Book) => Buffer;
responseDeserialize: (buffer: Uint8Array) => book_book_pb.Book;
}
interface IGetBooksViaAuthor {
path: string; // "/com.book.BookService/GetBooksViaAuthor"
requestStream: boolean; // false
responseStream: boolean; // true
requestType: book_book_pb.GetBookViaAuthor,
responseType: book_book_pb.Book,
requestSerialize: (arg: book_book_pb.GetBookViaAuthor) => Buffer;
requestDeserialize: (buffer: Uint8Array) => book_book_pb.GetBookViaAuthor;
responseSerialize: (arg: book_book_pb.Book) => Buffer;
responseDeserialize: (buffer: Uint8Array) => book_book_pb.Book;
}
interface IGetGreatestBook {
path: string; // "/com.book.BookService/GetGreatestBook"
requestStream: boolean; // true
responseStream: boolean; // false
requestType: book_book_pb.GetBookRequest,
responseType: book_book_pb.Book,
requestSerialize: (arg: book_book_pb.GetBookRequest) => Buffer;
requestDeserialize: (buffer: Uint8Array) => book_book_pb.GetBookRequest;
responseSerialize: (arg: book_book_pb.Book) => Buffer;
responseDeserialize: (buffer: Uint8Array) => book_book_pb.Book;
}
interface IGetBooks {
path: string; // "/com.book.BookService/GetBooks"
requestStream: boolean; // true
responseStream: boolean; // true
requestType: book_book_pb.GetBookRequest,
responseType: book_book_pb.Book,
requestSerialize: (arg: book_book_pb.GetBookRequest) => Buffer;
requestDeserialize: (buffer: Uint8Array) => book_book_pb.GetBookRequest;
responseSerialize: (arg: book_book_pb.Book) => Buffer;
responseDeserialize: (buffer: Uint8Array) => book_book_pb.Book;
}
export interface IBookServiceClient {
getBook(request: book_book_pb.GetBookRequest, callback: (error: Error | null, response: book_book_pb.Book) => void): grpc.ClientUnaryCall;
getBook(request: book_book_pb.GetBookRequest, metadata: grpc.Metadata, callback: (error: Error | null, response: book_book_pb.Book) => void): grpc.ClientUnaryCall;
getBooksViaAuthor(request: book_book_pb.GetBookViaAuthor, metadata?: grpc.Metadata): grpc.ClientReadableStream;
getGreatestBook(callback: (error: Error | null, response: book_book_pb.Book) => void): grpc.ClientWritableStream;
getGreatestBook(callback: (error: Error | null, metadata: grpc.Metadata, response: book_book_pb.Book) => void): grpc.ClientWritableStream;
getBooks(): grpc.ClientDuplexStream;
getBooks(metadata: grpc.Metadata): grpc.ClientDuplexStream;
}
export const BookServiceService: IBookServiceService;
export class BookServiceClient extends grpc.Client implements IBookServiceClient {
constructor(address: string, credentials: any, options?: grpc.IClientOptions);
public getBook(request: book_book_pb.GetBookRequest, callback: (error: Error | null, response: book_book_pb.Book) => void): grpc.ClientUnaryCall;
public getBook(request: book_book_pb.GetBookRequest, metadata: grpc.Metadata, callback: (error: Error | null, response: book_book_pb.Book) => void): grpc.ClientUnaryCall;
public getBooksViaAuthor(request: book_book_pb.GetBookViaAuthor, metadata?: grpc.Metadata): grpc.ClientReadableStream;
public getGreatestBook(callback: (error: Error | null, response: book_book_pb.Book) => void): grpc.ClientWritableStream;
public getGreatestBook(callback: (error: Error | null, metadata: grpc.Metadata, response: book_book_pb.Book) => void): grpc.ClientWritableStream;
public getBooks(): grpc.ClientDuplexStream;
public getBooks(metadata: grpc.Metadata): grpc.ClientDuplexStream;
}
// GENERATED CODE -- DO NOT EDIT!
'use strict';
var grpc = require('grpc');
var book_book_pb = require('../book/book_pb.js');
function serialize_com_book_Book(arg) {
if (!(arg instanceof book_book_pb.Book)) {
throw new Error('Expected argument of type com.book.Book');
}
return new Buffer(arg.serializeBinary());
}
function deserialize_com_book_Book(buffer_arg) {
return book_book_pb.Book.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_com_book_GetBookRequest(arg) {
if (!(arg instanceof book_book_pb.GetBookRequest)) {
throw new Error('Expected argument of type com.book.GetBookRequest');
}
return new Buffer(arg.serializeBinary());
}
function deserialize_com_book_GetBookRequest(buffer_arg) {
return book_book_pb.GetBookRequest.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_com_book_GetBookViaAuthor(arg) {
if (!(arg instanceof book_book_pb.GetBookViaAuthor)) {
throw new Error('Expected argument of type com.book.GetBookViaAuthor');
}
return new Buffer(arg.serializeBinary());
}
function deserialize_com_book_GetBookViaAuthor(buffer_arg) {
return book_book_pb.GetBookViaAuthor.deserializeBinary(new Uint8Array(buffer_arg));
}
var BookServiceService = exports.BookServiceService = {
getBook: {
path: '/com.book.BookService/GetBook',
requestStream: false,
responseStream: false,
requestType: book_book_pb.GetBookRequest,
responseType: book_book_pb.Book,
requestSerialize: serialize_com_book_GetBookRequest,
requestDeserialize: deserialize_com_book_GetBookRequest,
responseSerialize: serialize_com_book_Book,
responseDeserialize: deserialize_com_book_Book,
},
getBooksViaAuthor: {
path: '/com.book.BookService/GetBooksViaAuthor',
requestStream: false,
responseStream: true,
requestType: book_book_pb.GetBookViaAuthor,
responseType: book_book_pb.Book,
requestSerialize: serialize_com_book_GetBookViaAuthor,
requestDeserialize: deserialize_com_book_GetBookViaAuthor,
responseSerialize: serialize_com_book_Book,
responseDeserialize: deserialize_com_book_Book,
},
getGreatestBook: {
path: '/com.book.BookService/GetGreatestBook',
requestStream: true,
responseStream: false,
requestType: book_book_pb.GetBookRequest,
responseType: book_book_pb.Book,
requestSerialize: serialize_com_book_GetBookRequest,
requestDeserialize: deserialize_com_book_GetBookRequest,
responseSerialize: serialize_com_book_Book,
responseDeserialize: deserialize_com_book_Book,
},
getBooks: {
path: '/com.book.BookService/GetBooks',
requestStream: true,
responseStream: true,
requestType: book_book_pb.GetBookRequest,
responseType: book_book_pb.Book,
requestSerialize: serialize_com_book_GetBookRequest,
requestDeserialize: deserialize_com_book_GetBookRequest,
responseSerialize: serialize_com_book_Book,
responseDeserialize: deserialize_com_book_Book,
},
};
exports.BookServiceClient = grpc.makeGenericClientConstructor(BookServiceService);
// package: com.book
// file: book/book.proto
import * as jspb from "google-protobuf";
export class Book extends jspb.Message {
getIsbn(): number;
setIsbn(value: number): void;
getTitle(): string;
setTitle(value: string): void;
getAuthor(): string;
setAuthor(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): Book.AsObject;
static toObject(includeInstance: boolean, msg: Book): Book.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: Book, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): Book;
static deserializeBinaryFromReader(message: Book, reader: jspb.BinaryReader): Book;
}
export namespace Book {
export type AsObject = {
isbn: number,
title: string,
author: string,
}
}
export class GetBookRequest extends jspb.Message {
getIsbn(): number;
setIsbn(value: number): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetBookRequest.AsObject;
static toObject(includeInstance: boolean, msg: GetBookRequest): GetBookRequest.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: GetBookRequest, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): GetBookRequest;
static deserializeBinaryFromReader(message: GetBookRequest, reader: jspb.BinaryReader): GetBookRequest;
}
export namespace GetBookRequest {
export type AsObject = {
isbn: number,
}
}
export class GetBookViaAuthor extends jspb.Message {
getAuthor(): string;
setAuthor(value: string): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetBookViaAuthor.AsObject;
static toObject(includeInstance: boolean, msg: GetBookViaAuthor): GetBookViaAuthor.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: GetBookViaAuthor, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): GetBookViaAuthor;
static deserializeBinaryFromReader(message: GetBookViaAuthor, reader: jspb.BinaryReader): GetBookViaAuthor;
}
export namespace GetBookViaAuthor {
export type AsObject = {
author: string,
}
}
export class BookStore extends jspb.Message {
getName(): string;
setName(value: string): void;
getBooksMap(): jspb.Map<number, string>;
clearBooksMap(): void;
serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): BookStore.AsObject;
static toObject(includeInstance: boolean, msg: BookStore): BookStore.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: BookStore, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): BookStore;
static deserializeBinaryFromReader(message: BookStore, reader: jspb.BinaryReader): BookStore;
}
export namespace BookStore {
export type AsObject = {
name: string,
booksMap: Array<[number, string]>,
}
}
export enum EnumSample {
UNKNOWN = 0,
STARTED = 1,
RUNNING = 1,
}
/**
* @fileoverview
* @enhanceable
* @suppress {messageConventions} JS Compiler reports an error if a variable or
* field starts with 'MSG_' and isn't a translatable message.
* @public
*/
// GENERATED CODE -- DO NOT EDIT!
var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
goog.exportSymbol('proto.com.book.Book', null, global);
goog.exportSymbol('proto.com.book.BookStore', null, global);
goog.exportSymbol('proto.com.book.EnumSample', null, global);
goog.exportSymbol('proto.com.book.GetBookRequest', null, global);
goog.exportSymbol('proto.com.book.GetBookViaAuthor', null, global);
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.com.book.Book = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.com.book.Book, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.com.book.Book.displayName = 'proto.com.book.Book';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.com.book.Book.prototype.toObject = function(opt_includeInstance) {
return proto.com.book.Book.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.com.book.Book} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.Book.toObject = function(includeInstance, msg) {
var f, obj = {
isbn: jspb.Message.getFieldWithDefault(msg, 1, 0),
title: jspb.Message.getFieldWithDefault(msg, 2, ""),
author: jspb.Message.getFieldWithDefault(msg, 3, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.com.book.Book}
*/
proto.com.book.Book.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.com.book.Book;
return proto.com.book.Book.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.com.book.Book} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.com.book.Book}
*/
proto.com.book.Book.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {number} */ (reader.readInt64());
msg.setIsbn(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setTitle(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setAuthor(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.com.book.Book.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.com.book.Book.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.com.book.Book} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.Book.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getIsbn();
if (f !== 0) {
writer.writeInt64(
1,
f
);
}
f = message.getTitle();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
f = message.getAuthor();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
};
/**
* optional int64 isbn = 1;
* @return {number}
*/
proto.com.book.Book.prototype.getIsbn = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
};
/** @param {number} value */
proto.com.book.Book.prototype.setIsbn = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* optional string title = 2;
* @return {string}
*/
proto.com.book.Book.prototype.getTitle = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.com.book.Book.prototype.setTitle = function(value) {
jspb.Message.setField(this, 2, value);
};
/**
* optional string author = 3;
* @return {string}
*/
proto.com.book.Book.prototype.getAuthor = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/** @param {string} value */
proto.com.book.Book.prototype.setAuthor = function(value) {
jspb.Message.setField(this, 3, value);
};
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.com.book.GetBookRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.com.book.GetBookRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.com.book.GetBookRequest.displayName = 'proto.com.book.GetBookRequest';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.com.book.GetBookRequest.prototype.toObject = function(opt_includeInstance) {
return proto.com.book.GetBookRequest.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.com.book.GetBookRequest} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.GetBookRequest.toObject = function(includeInstance, msg) {
var f, obj = {
isbn: jspb.Message.getFieldWithDefault(msg, 1, 0)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.com.book.GetBookRequest}
*/
proto.com.book.GetBookRequest.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.com.book.GetBookRequest;
return proto.com.book.GetBookRequest.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.com.book.GetBookRequest} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.com.book.GetBookRequest}
*/
proto.com.book.GetBookRequest.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {number} */ (reader.readInt64());
msg.setIsbn(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.com.book.GetBookRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.com.book.GetBookRequest.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.com.book.GetBookRequest} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.GetBookRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getIsbn();
if (f !== 0) {
writer.writeInt64(
1,
f
);
}
};
/**
* optional int64 isbn = 1;
* @return {number}
*/
proto.com.book.GetBookRequest.prototype.getIsbn = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
};
/** @param {number} value */
proto.com.book.GetBookRequest.prototype.setIsbn = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.com.book.GetBookViaAuthor = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.com.book.GetBookViaAuthor, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.com.book.GetBookViaAuthor.displayName = 'proto.com.book.GetBookViaAuthor';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.com.book.GetBookViaAuthor.prototype.toObject = function(opt_includeInstance) {
return proto.com.book.GetBookViaAuthor.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.com.book.GetBookViaAuthor} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.GetBookViaAuthor.toObject = function(includeInstance, msg) {
var f, obj = {
author: jspb.Message.getFieldWithDefault(msg, 1, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.com.book.GetBookViaAuthor}
*/
proto.com.book.GetBookViaAuthor.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.com.book.GetBookViaAuthor;
return proto.com.book.GetBookViaAuthor.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.com.book.GetBookViaAuthor} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.com.book.GetBookViaAuthor}
*/
proto.com.book.GetBookViaAuthor.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setAuthor(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.com.book.GetBookViaAuthor.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.com.book.GetBookViaAuthor.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.com.book.GetBookViaAuthor} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.GetBookViaAuthor.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getAuthor();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
};
/**
* optional string author = 1;
* @return {string}
*/
proto.com.book.GetBookViaAuthor.prototype.getAuthor = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.com.book.GetBookViaAuthor.prototype.setAuthor = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.com.book.BookStore = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.com.book.BookStore, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.com.book.BookStore.displayName = 'proto.com.book.BookStore';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.com.book.BookStore.prototype.toObject = function(opt_includeInstance) {
return proto.com.book.BookStore.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.com.book.BookStore} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.BookStore.toObject = function(includeInstance, msg) {
var f, obj = {
name: jspb.Message.getFieldWithDefault(msg, 1, ""),
booksMap: (f = msg.getBooksMap()) ? f.toObject(includeInstance, undefined) : []
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.com.book.BookStore}
*/
proto.com.book.BookStore.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.com.book.BookStore;
return proto.com.book.BookStore.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.com.book.BookStore} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.com.book.BookStore}
*/
proto.com.book.BookStore.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setName(value);
break;
case 2:
var value = msg.getBooksMap();
reader.readMessage(value, function(message, reader) {
jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readInt64, jspb.BinaryReader.prototype.readString);
});
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.com.book.BookStore.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.com.book.BookStore.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.com.book.BookStore} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.com.book.BookStore.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getName();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getBooksMap(true);
if (f && f.getLength() > 0) {
f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeInt64, jspb.BinaryWriter.prototype.writeString);
}
};
/**
* optional string name = 1;
* @return {string}
*/
proto.com.book.BookStore.prototype.getName = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.com.book.BookStore.prototype.setName = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* map<int64, string> books = 2;
* @param {boolean=} opt_noLazyCreate Do not create the map if
* empty, instead returning `undefined`
* @return {!jspb.Map<number,string>}
*/
proto.com.book.BookStore.prototype.getBooksMap = function(opt_noLazyCreate) {
return /** @type {!jspb.Map<number,string>} */ (
jspb.Message.getMapField(this, 2, opt_noLazyCreate,
null));
};
proto.com.book.BookStore.prototype.clearBooksMap = function() {
this.getBooksMap().clear();
};
/**
* @enum {number}
*/
proto.com.book.EnumSample = {
UNKNOWN: 0,
STARTED: 1,
RUNNING: 1
};
goog.object.extend(exports, proto.com.book);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment