byte[] snappyCompress(in byte[] plaintext) { import deimos.snappy.snappy;size_t output_length = snappy_max_compressed_length(plaintext.length);
byte[] output = new byte[output_length];if(snappy_compress(cast(char*)plaintext.ptr, plaintext.length, cast(char*)output.ptr, &output_length) == SNAPPY_OK) {
byte[] compressed = output[0..output_length]; // <---- do something magical here return compressed; } assert(0); }
Snappy works on bytes, not text, char is a wrong type there.