Snappy.NET Straightforward wrapper around the underlying native Snappy library. You can compress, uncompress, and validate fixed-size buffers without framing overhead. Methods of this class forward their parameters directly to the native code without unnecessary buffer copying. Compresses byte buffer using Snappy compression. Input buffer containing data to be compressed. Offset into the input buffer where input data is located. Size of input data in the input buffer. Zero-length input is allowed. There's no maximum input size. Output buffer where compressed data will be stored. Buffer length minus outOffset must be equal or higher than return value of GetMaxCompressedLength method. Offset into the output buffer where compressed data will be stored. Length of compressed data written into the output buffer. Compresses byte buffer using Snappy compression. Input buffer containing data to be compressed. Zero-length input is allowed. Compressed data. Decompresses data previously compressed with Snappy. Input buffer containing compressed data. Offset of compressed data within the input buffer. Length of compressed data within the input buffer. Output buffer where decompressed data will be written. Buffer length minus outOffset must be equal or higher than return value of GetUncompressedLength method. Offset into the output buffer where decompressed data will be stored. Length of decompressed data written into the output buffer. Decompresses data previously compressed with Snappy. Input buffer containing compressed data. Decompressed data. Estimates maximum length of compressed data. Note that compressed data may be slightly larger than uncompressed data in some extreme cases of uncompressible data. Length of uncompressed data used as a basis for calculation of maximum length of compressed data. Maximum length of compressed data given input of length inLength. Retrieves length of uncompressed data for given buffer of compressed data. This is O(1) lookup that merely parses first few bytes of the compressed buffer where the length has been recorded during compression. Input buffer containing compressed data. Offset where compressed data is located in the input buffer. Length of compressed data in the input buffer. Exact length of uncompressed data encoded in the input buffer. Retrieves length of uncompressed data for given buffer of compressed data. This is O(1) lookup that merely parses first few bytes of the compressed buffer where the length has been recorded during compression. Input buffer containing compressed data. Exact length of uncompressed data encoded in the input buffer. Checks integrity of compressed data. This method performs sanity checks that ensure that the buffer can be decompressed. It doesn't check integrity of data. It merely ensures that decompression will succeed with _some_ result. CRC or other data integrity checks can be provided by higher level protocols like the Snappy framing format. Input buffer containing compressed data. Offset where compressed data is located in the input buffer. Length of compressed data in the input buffer. True if the buffer contains valid Snappy compressed block. False otherwise. Checks integrity of compressed data. This method performs sanity checks that ensure that the buffer can be decompressed. It doesn't check integrity of data. It merely ensures that decompression will succeed with _some_ result. CRC or other data integrity checks can be provided by higher level protocols like the Snappy framing format. Input buffer containing compressed data. True if the buffer contains valid Snappy compressed block. False otherwise. Represents single Snappy frame that conforms to Snappy framing format. Maximum size of uncompressed data in Snappy frame. It's 64KB in current version of the format. Stream identifier text. It is found in ASCII in identifier frame that leads the stream of Snappy frames. Create new Snappy frame. Frame is initialized to zero-length padding frame by default. Resets this frame to stream identifier frame. First frame in the stream must be identifier frame. Resets this frame to padding frame of specified size. Size of padding data excluding the 4 bytes of frame header. Maximum padding size is 16MB. Resets this frame to contain compressed data. Uncompressed data that is compressed by this method before being stored in the frame. Maximum data size is 64KB. Resets this frame to contain compressed data. Input buffer containing uncompressed data that is compressed by this method before being stored in the frame. Offset of uncompressed data in the input buffer. Size of uncompressed data in the input buffer. Maximum data size is 64KB. Resets this frame to contain uncompressed data. Uncompressed data to store in the frame. Maximum data size is 64KB. Resets this frame to contain uncompressed data. Input buffer containing uncompressed data to be stored in this frame. Offset of uncompressed data in the input buffer. Size of uncompressed data in the input buffer. Maximum data size is 64KB. Retrieves data from the frame. Data is uncompressed before being stored in the output buffer. CRC of the data is checked and CRC failure results in exception. Output buffer where uncompressed data is stored. It must be at least DataLength bytes long. Retrieves data from the frame. Data is uncompressed before being stored in the output buffer. CRC of the data is checked and CRC failure results in exception. Output buffer where uncompressed data is stored. Buffer length minus offset must be at least DataLength bytes. Offset into the output buffer where uncompressed data will be stored. Retrieves Snappy frame from underlying stream. Retrieved frame data is stored in properties of this object. Return value indicates end of stream. Exceptions indicate data integrity errors and underlying stream errors. Underlying stream that will be read by this method. True if frame was successfully retrieved. False if there are no more frames in the stream, i.e. the end of stream has been reached. Note that reaching the end of stream in the middle of the frame is considered an error and causes exception instead. Retrieves Snappy frame from underlying stream. Retrieved frame data is stored in properties of this object. Return value indicates end of stream. Exceptions indicate data integrity errors and underlying stream errors. Underlying stream that will be read by this method. True if frame was successfully retrieved. False if there are no more frames in the stream, i.e. the end of stream has been reached. Note that reaching the end of stream in the middle of the frame is considered an error and causes exception instead. Retrieves Snappy frame from underlying stream. Retrieved frame data is stored in properties of this object. Return value indicates end of stream. Exceptions indicate data integrity errors and underlying stream errors. Underlying stream that will be read by this method. Cancellation token that can be used to cancel the read operation. True if frame was successfully retrieved. False if there are no more frames in the stream, i.e. the end of stream has been reached. Note that reaching the end of stream in the middle of the frame is considered an error and causes exception instead. Writes the frame into the underlying stream. Underlying stream where the frame will be written. Writes the frame into the underlying stream. Underlying stream where the frame will be written. Task object indicating completion of the write. Writes the frame into the underlying stream. Underlying stream where the frame will be written. Cancellation token that can be used to cancel the write operation. Task object indicating completion of the write. Type of Snappy frame. It contains decoded frame type upon deserialization. It is set automatically by Set* methods. Data checksum is present in compressed and uncompressed frames. Otherwise it is zero. It is computed automatically by Set* methods. It is automatically checked when reading data through Data property or GetData method. It is CRC-32C (Castagnoli) of the uncompressed data with final CRC obfuscated with transformation ((crc >> 15) | (crc << 17)) + 0xa282ead8. Length of uncompressed data for data frames. Querying this property takes O(1) time. For compressed and uncompressed data, data length is never larger than 64KB. For padding frames, this property is equal to the length of padding data. Identification frame has data length of 6. Data length is automatically set by Set* methods and upon frame deserialization. Uncompressed data in the frame. It is available only for frame type Compressed or Uncompressed. Querying this property triggers CRC check of the data, which might cause exceptions. Returned data is never larger than 64KB. Type of Snappy frame. Supported compressed frame containing Snappy compressed data. Supported uncompressed frame containing plain data. Beginning of the range of unsupported frame types reserved for future use. Exception is thrown if any such frame type is encountered. End of the range of unsupported frame types reserved for future use. Exception is thrown if any such frame type is encountered. Beginning of the range of unsupported frame types that are safe to skip. If encountered on input, data in these frames is skipped. End of the range of unsupported frame types that are safe to skip. If encountered on input, data in these frames is skipped. Padding frame. Data in this frame is ignored. Padding frames can be used for alignment purposes. Stream identifier frame. This frame contains text "sNaPpY". Compression stream similar to GZipStream except this one uses Snappy compression. This stream uses standard Snappy framing format that supports streams of unbounded size and includes CRC checksums of all transmitted data. This stream can operate in one of two modes: compression or decompression. When compressing, use Write* methods. When decompressing, use Read* methods. If SnappyStream is opened for compression and immediately closed, the resulting stream will be a valid Snappy stream containing zero bytes of uncompressed data. Creates new SnappyStream using specified mode of operation. Underlying stream holding compressed data. It is automatically closed when SnappyStream is closed. Use mode Compress if SnappyStream is used to compress data and write it to the underlying stream. Use mode Decompress if SnappyStream is used to decompress data that is retrieved in compressed form from the underlying stream. Creates new SnappyStream using specified mode of operation with an option to leave the underlying stream open. Underlying stream holding compressed data. Use mode Compress if SnappyStream is used to compress data and write it to the underlying stream. Use mode Decompress if SnappyStream is used to decompress data that is retrieved in compressed form from the underlying stream. False to close the underlying stream when SnappyStream is closed. True to leave the underlying stream open. Dispose the stream. Remaining data is flushed and underlying stream is closed. True to release both managed and unmanaged resources. False to release only unmanaged resources. Reads uncompressed data from underlying compressed stream. Output buffer where uncompressed data will be written. Offset into the output buffer where uncompressed data will be written. Maximum size of uncompressed data to read. Amount of data actually stored in the output buffer. This might be less than the count parameter if end of stream is encountered. Return value is zero if there is no more data in the stream. Reads uncompressed data from underlying compressed stream. Output buffer where uncompressed data will be written. Offset into the output buffer where uncompressed data will be written. Maximum size of uncompressed data to read. Cancellation token that can be used to cancel the read operation. Amount of data actually stored in the output buffer. This might be less than the count parameter if end of stream is encountered. Return value is zero if there is no more data in the stream. Reads single byte from the underlying stream. Byte read from the stream or -1 if end of stream has been reached. Compresses given uncompressed data and writes the compressed data to the underlying stream. This method will buffer some of the data in order to compress 64KB at a time. Use Flush method to write the data to the underlying stream immediately. Input buffer containing uncompressed data to be compressed and written to the underlying stream. Offset into the input buffer where uncompressed data is located. Length of the uncompressed data in the input buffer. Zero-length data has no effect on the stream. Compresses given uncompressed data and writes the compressed data to the underlying stream. This method will buffer some of the data in order to compress 64KB at a time. Use FlushAsync method to write the data to the underlying stream immediately. Input buffer containing uncompressed data to be compressed and written to the underlying stream. Offset into the input buffer where uncompressed data is located. Length of the uncompressed data in the input buffer. Zero-length data has no effect on the stream. Cancellation token that can be used to cancel the write operation. Task object indicating completion of the write. Writes single byte of uncompressed data to the stream and queues it for compression. This method will buffer data in order to compress 64KB at a time. Use Flush method to write the data to the underlying stream immediately. Byte of uncompressed data to be added to the stream. Flushes all data buffered by previous calls to Write* methods. Remaining data is compressed and written to the underlying stream. Flushes all data buffered by previous calls to Write* methods. Remaining data is compressed and written to the underlying stream. Cancellation token that can be used to cancel the flush operation. Task object indicating completion of the flush. Sets the length of the current stream. Not supported in SnappyStream. The desired length of the current stream in bytes. Sets the position within the current stream. Not supported in SnappyStream. A byte offset relative to the origin parameter. A value of type SeekOrigin indicating the reference point used to obtain the new position. Gets a value indicating whether the current stream supports reading. True for decompression stream. Gets a value indicating whether the current stream supports writing. True for compression stream. Gets a value indicating whether the current stream supports seeking. Always false for SnappyStream. Gets the length in bytes of the stream. Not supported in SnappyStream. Gets or sets the position within the current stream. Not supported in SnappyStream.