Static Public Member Functions | Private Member Functions | List of all members
com.google.protobuf.UnsafeByteOperations Class Reference

Static Public Member Functions

static ByteString unsafeWrap (byte[] buffer)
 
static ByteString unsafeWrap (byte[] buffer)
 
static ByteString unsafeWrap (byte[] buffer, int offset, int length)
 
static ByteString unsafeWrap (byte[] buffer, int offset, int length)
 
static ByteString unsafeWrap (ByteBuffer buffer)
 
static ByteString unsafeWrap (ByteBuffer buffer)
 
static void unsafeWriteTo (ByteString bytes, ByteOutput output) throws IOException
 
static void unsafeWriteTo (ByteString bytes, ByteOutput output) throws IOException
 

Private Member Functions

 UnsafeByteOperations ()
 
 UnsafeByteOperations ()
 

Detailed Description

Provides a number of unsafe byte operations to be used by advanced applications with high performance requirements. These methods are referred to as "unsafe" due to the fact that they potentially expose the backing buffer of a ByteString to the application.

DISCLAIMER: The methods in this class should only be called if it is guaranteed that the buffer backing the ByteString will never change! Mutation of a {} can lead to unexpected and undesirable consequences in your application, and will likely be difficult to debug. Proceed with caution! This can have a number of significant side affects that have spooky-action-at-a-distance-like behavior. In particular, if the bytes value changes out from under a Protocol Buffer:

Each of these issues will occur in parts of the code base that are entirely distinct from the parts of the code base modifying the buffer. In fact, both parts of the code base may be correct

Definition at line 65 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.

Constructor & Destructor Documentation

◆ UnsafeByteOperations() [1/2]

com.google.protobuf.UnsafeByteOperations.UnsafeByteOperations ( )
inlineprivate

◆ UnsafeByteOperations() [2/2]

com.google.protobuf.UnsafeByteOperations.UnsafeByteOperations ( )
inlineprivate

Member Function Documentation

◆ unsafeWrap() [1/6]

static ByteString com.google.protobuf.UnsafeByteOperations.unsafeWrap ( byte[]  buffer)
inlinestatic

An unsafe operation that returns a ByteString that is backed by the provided buffer.

Parameters
bufferthe buffer to be wrapped
Returns
a ByteString backed by the provided buffer

Definition at line 74 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.

◆ unsafeWrap() [2/6]

static ByteString com.google.protobuf.UnsafeByteOperations.unsafeWrap ( byte[]  buffer)
inlinestatic

An unsafe operation that returns a ByteString that is backed by the provided buffer.

Parameters
bufferthe buffer to be wrapped
Returns
a ByteString backed by the provided buffer

Definition at line 74 of file protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.

◆ unsafeWrap() [3/6]

static ByteString com.google.protobuf.UnsafeByteOperations.unsafeWrap ( byte[]  buffer,
int  offset,
int  length 
)
inlinestatic

An unsafe operation that returns a ByteString that is backed by a subregion of the provided buffer.

Parameters
bufferthe buffer to be wrapped
offsetthe offset of the wrapped region
lengththe number of bytes of the wrapped region
Returns
a ByteString backed by the provided buffer

Definition at line 87 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.

◆ unsafeWrap() [4/6]

static ByteString com.google.protobuf.UnsafeByteOperations.unsafeWrap ( byte[]  buffer,
int  offset,
int  length 
)
inlinestatic

An unsafe operation that returns a ByteString that is backed by a subregion of the provided buffer.

Parameters
bufferthe buffer to be wrapped
offsetthe offset of the wrapped region
lengththe number of bytes of the wrapped region
Returns
a ByteString backed by the provided buffer

Definition at line 87 of file protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.

◆ unsafeWrap() [5/6]

static ByteString com.google.protobuf.UnsafeByteOperations.unsafeWrap ( ByteBuffer  buffer)
inlinestatic

An unsafe operation that returns a ByteString that is backed by the provided buffer.

Parameters
bufferthe Java NIO buffer to be wrapped
Returns
a ByteString backed by the provided buffer

Definition at line 97 of file protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.

◆ unsafeWrap() [6/6]

static ByteString com.google.protobuf.UnsafeByteOperations.unsafeWrap ( ByteBuffer  buffer)
inlinestatic

An unsafe operation that returns a ByteString that is backed by the provided buffer.

Parameters
bufferthe Java NIO buffer to be wrapped
Returns
a ByteString backed by the provided buffer

Definition at line 97 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.

◆ unsafeWriteTo() [1/2]

static void com.google.protobuf.UnsafeByteOperations.unsafeWriteTo ( ByteString  bytes,
ByteOutput  output 
) throws IOException
inlinestatic

Writes the given ByteString to the provided ByteOutput. Calling this method may result in multiple operations on the target ByteOutput (i.e. for roped {}s). This method exposes the internal backing buffer(s) of the ByteString to the {} in order to avoid additional copying overhead. It would be possible for a malicious ByteOutput} to corrupt the ByteString}. Use with caution! NOTE: The ByteOutput MUST NOT modify the provided buffers. Doing so may result in corrupted data, which would be difficult to debug.

Parameters
bytesthe ByteString to be written
outputthe output to receive the bytes
Exceptions
IOExceptionif an I/O error occurs

Definition at line 117 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.

◆ unsafeWriteTo() [2/2]

static void com.google.protobuf.UnsafeByteOperations.unsafeWriteTo ( ByteString  bytes,
ByteOutput  output 
) throws IOException
inlinestatic

Writes the given ByteString to the provided ByteOutput. Calling this method may result in multiple operations on the target ByteOutput (i.e. for roped {}s). This method exposes the internal backing buffer(s) of the ByteString to the {} in order to avoid additional copying overhead. It would be possible for a malicious ByteOutput} to corrupt the ByteString}. Use with caution! NOTE: The ByteOutput MUST NOT modify the provided buffers. Doing so may result in corrupted data, which would be difficult to debug.

Parameters
bytesthe ByteString to be written
outputthe output to receive the bytes
Exceptions
IOExceptionif an I/O error occurs

Definition at line 117 of file protobuf/java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java.


The documentation for this class was generated from the following file:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:08