sink_result try_write_cur() { auto r = sink->write(std::move(cur_out)); if (!r) { if (r.s == sink_result::part) return sink_result(sink_result::would_block); return r; } prepare_out(); return r; }
virtual source_result read_next(size_t amount = 0) { sassert(pull); auto s = drive(); if (s == source_result::ok) { auto bucket = std::move(cur_out); prepare_out(); return source_result(std::move(bucket)); } return source_result(s); }
deflate_source(source const& src, bool compress, bool pull = true) : octet_reader(src) , pull(pull) , compress(compress) { str.zalloc = 0; str.zfree = 0; str.opaque = 0; if (compress) mz_deflateInit(&str, MZ_DEFAULT_COMPRESSION); else mz_inflateInit(&str); str.avail_in = 0; str.avail_out = 0; prepare_out(); }