Line data Source code
1 : // Copyright The OpenTelemetry Authors
2 : // SPDX-License-Identifier: Apache-2.0
3 :
4 : import 'dart:io';
5 : import 'dart:typed_data';
6 :
7 : /// The [GZip] encodes raw bytes to GZip compressed bytes and decodes GZip
8 : /// compressed bytes to raw bytes.
9 : ///
10 : /// It is implemented using `dart:io` on native platforms and platform-specific
11 : /// implementations in browsers.
12 : class GZip {
13 : /// Compress the [data] using gzip compression.
14 8 : Future<List<int>> compress(Uint8List data) async =>
15 16 : gzip.encoder.convert(data);
16 :
17 : /// Decode the gzip-compressed [data].
18 1 : Future<List<int>> decompress(Uint8List data) async =>
19 2 : gzip.decoder.convert(data);
20 : }
|