Skip to content

Commit 64332b7

Browse files
committed
Add missing docs
1 parent 0ab619c commit 64332b7

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

api/src/main/java/dev/freya02/discord/zstd/api/DiscordZstd.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
import java.io.InputStream;
66

7+
/**
8+
* Main interface which allows creating {@linkplain DiscordZstdContext decompression contexts},
9+
* and {@linkplain DiscordZstdDecompressorFactory decompressor factories}.
10+
*/
711
@NullMarked
812
public interface DiscordZstd {
913
/**
@@ -20,7 +24,7 @@ public interface DiscordZstd {
2024
* @param bufferSizeHint
2125
* A hint for the size of the buffer used for decompression,
2226
* must be larger than {@value DiscordZstdDecompressor#MIN_BUFFER_SIZE} or be equal to {@value DiscordZstdDecompressor#ZSTD_RECOMMENDED_BUFFER_SIZE}.
23-
* Typically, bigger buffers mean less decompression loops, it does not change inputs or outputs
27+
* <br>Typically, bigger buffers mean less decompression loops, it does not change inputs or outputs
2428
*
2529
* @throws IllegalArgumentException
2630
* If {@code bufferSize} is less than {@value DiscordZstdDecompressor#MIN_BUFFER_SIZE} and not {@value DiscordZstdDecompressor#ZSTD_RECOMMENDED_BUFFER_SIZE}

api/src/main/java/dev/freya02/discord/zstd/api/DiscordZstdContext.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,45 @@
44

55
import java.io.InputStream;
66

7+
/**
8+
* Wraps a Zstandard decompression context, it keeps track of the previous decompressed data,
9+
* allowing for greater compression ratios, but the data must be decompressed in the same order.
10+
*
11+
* <br>It can be used to decompress-as-you-consume with {@link InputStream InputStreams}.
12+
*
13+
* <p>Instances are <b>not</b> thread safe.
14+
*/
715
@NullMarked
816
public interface DiscordZstdContext {
17+
/**
18+
* Closes the context and frees resources.
19+
*
20+
* <p>If this is already closed, this is a no-op.
21+
*/
922
void close();
1023

24+
/**
25+
* Resets the current context so it can be used again.
26+
*
27+
* @throws IllegalStateException
28+
* If the context is closed
29+
*/
1130
void reset();
1231

32+
/**
33+
* Exceptions thrown by the {@link InputStream} will invalidate the decompression context,
34+
* in which case you will need to recreate a new one or call {@link #reset()},
35+
* as well as recreate a gateway connection.
36+
*
37+
* @param input
38+
* The data to decompress
39+
*
40+
* @throws IllegalArgumentException
41+
* If the provided input is {@code null}
42+
* @throws IllegalStateException
43+
* If the context is closed or in an errored state
44+
*
45+
* @return The new {@link InputStream}
46+
*/
1347
InputStream createInputStream(byte[] input);
1448
}

api/src/main/java/dev/freya02/discord/zstd/api/DiscordZstdProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import java.util.ServiceConfigurationError;
77
import java.util.ServiceLoader;
88

9+
/**
10+
* Entrypoint of {@code discord-zstd-java}. This is where you can get instances of {@link DiscordZstd}.
11+
*/
912
@NullMarked
1013
public class DiscordZstdProvider {
1114

0 commit comments

Comments
 (0)