47 DeflatePrivate(payload,
_buffer.AsSpan(num), endOfMessage, out var consumed, out var written, out var needsMoreOutput);
53 payload = payload.
Slice(consumed);
76 UnsafeDeflate(payload, output, out consumed, out written, out needsMoreOutput);
99 fixed (
byte* ptr =
input)
101 fixed (
byte* ptr2 = output)
103 _stream.NextIn = (
IntPtr)ptr;
104 _stream.AvailIn = (uint)
input.Length;
105 _stream.NextOut = (
IntPtr)ptr2;
106 _stream.AvailOut = (uint)output.
Length;
108 consumed = input.Length - (int)
_stream.AvailIn;
109 written = output.Length - (int)
_stream.AvailOut;
110 needsMoreBuffer = errorCode == ZLibNative.ErrorCode.BufError || _stream.AvailIn != 0;
117 fixed (
byte* ptr = output)
120 _stream.AvailIn = 0u;
121 _stream.NextOut = (
IntPtr)ptr;
122 _stream.AvailOut = (uint)output.
Length;
124 needsMoreBuffer = _stream.AvailOut < 6;
125 if (!needsMoreBuffer)
129 return output.Length - (int)
_stream.AvailOut;
150 string message =
text;
168 return zLibStreamHandle;
static ArrayPool< T > Shared
static ErrorCode CreateZLibStreamForDeflate(out ZLibStreamHandle zLibStreamHandle, CompressionLevel level, int windowBits, int memLevel, CompressionStrategy strategy)
static byte Max(byte val1, byte val2)
WebSocketDeflater(int windowBits, bool persisted)
ZLibNative.ZLibStreamHandle _stream
ZLibNative.ZLibStreamHandle CreateDeflater()
ReadOnlySpan< byte > Deflate(ReadOnlySpan< byte > payload, bool endOfMessage)
unsafe void UnsafeDeflate(ReadOnlySpan< byte > input, Span< byte > output, out int consumed, out int written, out bool needsMoreBuffer)
void DeflatePrivate(ReadOnlySpan< byte > payload, Span< byte > output, bool endOfMessage, out int consumed, out int written, out bool needsMoreOutput)
unsafe int UnsafeFlush(Span< byte > output, out bool needsMoreBuffer)
static ZLibNative.ErrorCode Deflate(ZLibNative.ZLibStreamHandle stream, ZLibNative.FlushCode flushCode)
static string ZLibErrorNotEnoughMemory
static string ZLibErrorDLLLoadError
static string ZLibErrorInconsistentStream
static string ZLibErrorUnexpected
static readonly IntPtr Zero
ReadOnlySpan< T > Slice(int start)
Span< T > Slice(int start)