You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-8Lines changed: 9 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,18 @@
6
6
7
7
# Rebol/Zstd
8
8
9
-
[Zstandard](https://github.com/facebook/zstd) extension for [Rebol3](https://github.com/Oldes/Rebol3) (version 3.20.5 and higher)
9
+
[Zstandard](https://github.com/facebook/zstd)compression extension for [Rebol3](https://github.com/Oldes/Rebol3) (version 3.20.5 or newer)
10
10
11
-
## Usage
12
-
Basic usage is just using `import zstd` and then use `zstd` method with default Rebol `compress` and `decompress` functions. Like:
11
+
## Basic usage
12
+
Use Zstandard as a codec for the standard compress and decompress functions:
13
13
```rebol
14
14
import zstd
15
15
bin: compress "some data" 'zstd
16
16
txt: to string! decompress bin 'zstd
17
17
```
18
18
19
-
Additionally, this extension provides a streaming API, allowing data to be (de)compressed in chunks without requiring it to be fully loaded into memory.
19
+
## Streaming API
20
+
The streaming API lets you process data in chunks, which is useful for large inputs, pipes, or network streams.
20
21
```rebol
21
22
zstd: import zstd ;; Import the module and assign it to a variable
22
23
enc: zstd/make-encoder ;; Initialize the Zstandard encoder state handle
@@ -29,6 +30,7 @@ bin1: zstd/read :enc
29
30
;; Continue with other data and use `/finish` to encode all remaining input
30
31
;; and mark the stream as complete.
31
32
bin2: zstd/write/finish :enc " from Rebol!"
33
+
32
34
;; Decompress both compressed blocks again (using extension's command this time):
33
35
text: to string! zstd/decompress join bin1 bin2
34
36
;== "Hello Zstandard from Rebol!"
@@ -41,14 +43,13 @@ text: to string! zstd/read :dec ;; Resolve decompressed data
41
43
;== "Hello Zstandard from Rebol!"
42
44
```
43
45
44
-
Using this streaming API, you can write functions like these:
46
+
### Example: file helpers
47
+
These (basic) examples show how to build file-level utilities on top of the streaming API.
0 commit comments