Interface DiscordZstdContext


@NullMarked public interface DiscordZstdContext
Wraps a Zstandard decompression context, it keeps track of the previous decompressed data, allowing for greater compression ratios, but the data must be decompressed in the same order.
It can be used to decompress-as-you-consume with InputStreams.

Instances are not thread safe.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the context and frees resources.
    createInputStream(byte[] input)
    Exceptions thrown by the InputStream will invalidate the decompression context, in which case you will need to recreate a new one or call reset(), as well as recreate a gateway connection.
    void
    Resets the current context so it can be used again.
  • Method Details

    • close

      void close()
      Closes the context and frees resources.

      If this is already closed, this is a no-op.

    • reset

      void reset()
      Resets the current context so it can be used again.
      Throws:
      IllegalStateException - If the context is closed
    • createInputStream

      InputStream createInputStream(byte[] input)
      Exceptions thrown by the InputStream will invalidate the decompression context, in which case you will need to recreate a new one or call reset(), as well as recreate a gateway connection.
      Parameters:
      input - The data to decompress
      Returns:
      The new InputStream
      Throws:
      IllegalArgumentException - If the provided input is null
      IllegalStateException - If the context is closed or in an errored state