mirror of
https://github.com/chylex/Brotli-Builder.git
synced 2024-11-24 22:42:50 +01:00
21 lines
789 B
C#
21 lines
789 B
C#
using BrotliLib.Brotli.Components;
|
|
using BrotliLib.Brotli.Components.Data;
|
|
using BrotliLib.Brotli.Components.Header;
|
|
using BrotliLib.Brotli.Encode;
|
|
using BrotliLib.Collections;
|
|
|
|
namespace BrotliImpl.Encoders{
|
|
/// <summary>
|
|
/// Encodes bytes into a series of compressed meta-blocks, where each contains a single insert&copy command with each byte stored as a literal.
|
|
/// </summary>
|
|
public class EncodeLiterals : IBrotliEncoder{
|
|
public (MetaBlock, BrotliEncodeInfo) Encode(BrotliEncodeInfo info){
|
|
var bytes = CollectionHelper.SliceAtMost(info.Bytes, DataLength.MaxUncompressedBytes).ToArray();
|
|
|
|
return info.NewBuilder()
|
|
.AddInsert(Literal.FromBytes(bytes))
|
|
.Build(info);
|
|
}
|
|
}
|
|
}
|