1/** 2 * @fileoverview Exposes internal only functions for ByteString. The 3 * corresponding BUILD rule restricts access to this file to only the binary 4 * kernel and APIs directly using the binary kernel. 5 */ 6goog.module('protobuf.byteStringInternal'); 7 8const ByteString = goog.require('protobuf.ByteString'); 9 10/** 11 * Constructs a ByteString from an Uint8Array. DON'T MODIFY the underlying 12 * ArrayBuffer, since the ByteString directly uses it without making a copy. 13 * @param {!Uint8Array} bytes 14 * @return {!ByteString} 15 */ 16function byteStringFromUint8ArrayUnsafe(bytes) { 17 return ByteString.fromUint8ArrayUnsafe(bytes); 18} 19 20/** 21 * Returns this ByteString as an Uint8Array. DON'T MODIFY the returned array, 22 * since the ByteString holds the reference to the same array. 23 * @param {!ByteString} bytes 24 * @return {!Uint8Array} 25 */ 26function byteStringToUint8ArrayUnsafe(bytes) { 27 return bytes.toUint8ArrayUnsafe(); 28} 29 30exports = { 31 byteStringFromUint8ArrayUnsafe, 32 byteStringToUint8ArrayUnsafe, 33}; 34