Interface ZeroCopySupport.DisposableByteString

All Superinterfaces:
AutoCloseable, Closeable
Enclosing class:
ZeroCopySupport

@BetaApi @InternalExtensionOnly public static interface ZeroCopySupport.DisposableByteString extends AutoCloseable, Closeable
Represents an object that can be accessed as a ByteString, but has a lifecycle that requires being explicitly closed in order to free up resources.

Instances of this class should be used in a try-with-resources to ensure they are released.


 try (DisposableByteString disposableByteString = ...) {
   System.out.println(disposableByteString.byteString().size());
 }
 
Since:
2.51.0 This new api is in preview and is subject to breaking changes.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.protobuf.ByteString
    Get the ByteString representation of the underlying resources
    void
    Signal the underlying resources that they can be released.
  • Method Details

    • byteString

      com.google.protobuf.ByteString byteString()
      Get the ByteString representation of the underlying resources
    • close

      void close() throws IOException
      Signal the underlying resources that they can be released.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException