XzEncoderConverter class
Not a standard dart:convert Codec because it doesn't perform simple
byte-to-byte conversions, acting purely as a StreamTransformer.
It stores the data rather than compressing it.
That is all XZEncoder does today
Please note that onDone may never be called on failure, you have to listen for both onError and onDone to identify the end of stream. Example for .encoder:
Stream<ArchiveFile> filesOf(Directory dir) async* {
await for (final entity in dir.list(recursive: true)) {
if (entity is File) {
final input = InputFileStream(entity.path);
try {
yield ArchiveFile.stream(
p.relative(entity.path, from: dir.path), input);
} finally {
// Runs once the encoder has written the entry, or when it is
// cancelled
await input.close();
}
}
}
}
final upload =
await HttpClient().putUrl(Uri.parse('https://example.com/backup'));
upload.headers.contentType = ContentType('application', 'zstd');
await upload.addStream(filesOf(Directory('data'))
// also available for zip/tar
.transform(zipCodec.encoder) // Stream<ArchiveFile> -> Stream<List<int>>
// also available for zstd/xz/bzip2
.transform(zstdCodec.encoder));
final response = await upload.close();
Constructors
- XzEncoderConverter({XZCheck check = XZCheck.crc64})
-
const
Properties
Methods
-
bind(
Stream< List< stream) → Stream<int> >List< int> > -
A stream hears a failure once. The sink throws it again on every later
call, so the input after it is dropped here, as gzip and zlib in dart:io
drop it
inherited
-
cast<
RS, RT> () → Converter< RS, RT> -
Provides a
Converter<RS, RT>view of this stream transformer.inherited -
convert(
List< int> input) → List<int> -
Converts
inputand returns the result of the conversion.inherited -
fuse<
TT> (Converter< List< other) → Converter<int> , TT>List< int> , TT> -
Fuses
thiswithother.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
startChunkedConversion(
Sink< List< sink) → ByteConversionSinkint> > -
Starts a chunked conversion.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited