{"id":373517,"date":"2024-05-21T05:38:09","date_gmt":"2024-05-21T05:38:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=373517"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=373517","title":{"rendered":"<span>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Rust<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/7c8\/706\/b02\/7c8706b02fad5737360b076f85731b92.jpg\" width=\"1280\" height=\"720\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7c8\/706\/b02\/7c8706b02fad5737360b076f85731b92.jpg\" data-blurred=\"true\"\/><\/figure>\n<p><strong>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/strong><\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u042f\u041f Rust. \u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u043b\u0438 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438. \u0420\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442 \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f: <em>\u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438<\/em> \u0438 <em>\u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c.<\/em><\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u0436\u0430\u0442\u0438\u044f \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c<\/strong><\/p>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u0434\u0435<\/strong>;<\/p>\n<\/li>\n<li>\n<p><strong>\u0410\u0440\u0445\u0438\u0432\u0430\u0446\u0438\u044f\u0445<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0436\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/strong>, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a PNG, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0430\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 &#8212;  <strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/strong> \u0438 <strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u041b\u0435\u043c\u043f\u0435\u043b\u044f-\u0417\u0438\u0432\u0430-\u0412\u0435\u043b\u0447\u0430<\/strong>.<\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u0436\u0430\u0442\u0438\u044f \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438<\/strong><\/p>\n<p>\u0410 \u0432\u043e\u0442 \u044d\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u0430\u043c, \u0433\u0434\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u043e\u0442\u0435\u0440\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0432\u0430\u0436\u043d\u0430, \u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p><strong>\u0412\u0438\u0434\u0435\u043e \u0438 \u0430\u0443\u0434\u0438\u043e<\/strong> \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u0433\u0434\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u044b \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0432\u0437\u0433\u043b\u044f\u0434\u0443 \u0438\u043b\u0438 \u0441\u043b\u0443\u0445\u0443;<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0436\u0430\u0442\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/strong> \u0434\u043b\u044f \u0432\u0435\u0431\u0430, \u0433\u0434\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0441\u0443\u043f\u0435\u0440\u0441\u043a\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0442\u0430\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 &#8212; <strong>DCT<\/strong>.<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u043a\u0440\u0430\u0442\u043a\u043e \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043f\u0440\u043e \u043e\u0441\u043d\u043e\u0432\u044b, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c. \u0418 \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 &#8212; <strong>zstd<\/strong>.<\/p>\n<h2>zstd<\/h2>\n<p><code>zstd<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435, \u0442\u0430\u043a \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/strong><\/p>\n<p><code>encoder<\/code><strong> <\/strong>\u0438<strong> <\/strong><code>decoder<\/code> \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. <code>encoder<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <code>decoder<\/code> \u0447\u0438\u0442\u0430\u0435\u0442 \u0441\u0436\u0430\u0442\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438\u0445.<\/p>\n<p><code>stream<\/code>: \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u0438\u043c\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>copy_encode<\/code> \u0438 <code>copy_decode<\/code> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 Rust.<\/p>\n<p><code>dict<\/code>: \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c\u0438 \u0441\u0436\u0430\u0442\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0436\u0438\u043c\u0430\u0435\u0442 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u0436\u0438\u043c\u0430\u0442\u044c.<\/p>\n<p><code>encode_all<\/code> \u0438 <code>decode_all<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u043b\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p><code>compression_level_range<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <code>async-compression<\/code> \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442 <code>zstd<\/code> \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 Rust, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<p><code>DEFAULT_COMPRESSION_LEVEL<\/code>: \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0430\u044f \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f<\/p>\n<pre><code class=\"rust\">use std::io; use zstd::stream::{read::Decoder, write::Encoder};  \/\/ \u0441\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 fn compress(data: &amp;[u8], level: i32) -> io::Result&lt;Vec&lt;u8>> {     let mut encoder = Encoder::new(Vec::new(), level)?;     io::copy(&amp;mut &amp;data[..], &amp;mut encoder)?;     let compressed = encoder.finish()?;     Ok(compressed) }  \/\/ \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 fn decompress(data: &amp;[u8]) -> io::Result&lt;Vec&lt;u8>> {     let mut decoder = Decoder::new(&amp;data[..])?;     let mut decompressed = Vec::new();     io::copy(&amp;mut decoder, &amp;mut decompressed)?;     Ok(decompressed) }<\/code><\/pre>\n<p>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f<\/p>\n<pre><code class=\"rust\">use async_compression::stream::{ZstdDecoder, ZstdEncoder}; use tokio::io::{self, AsyncReadExt, AsyncWriteExt};  async fn compress_async(input: &amp;[u8], level: i32) -> io::Result&lt;Vec&lt;u8>> {     let reader = io::Cursor::new(input);     let stream = ZstdEncoder::with_quality(reader, level);     let mut writer = Vec::new();     let mut stream = io::BufReader::new(stream);      while let Some(bytes) = stream.fill_buf().await? {         writer.write_all(bytes)?;         stream.consume(bytes.len());     }     Ok(writer) }  async fn decompress_async(input: &amp;[u8]) -> io::Result&lt;Vec&lt;u8>> {     let reader = io::Cursor::new(input);     let stream = ZstdDecoder::new(reader);     let mut writer = Vec::new();     let mut stream = io::BufReader::new(stream);      while let Some(bytes) = stream.fill_buf().await? {         writer.write_all(bytes)?;         stream.consume(bytes.len());     }     Ok(writer) }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>Encoder<\/code>. \u0423\u0440\u043e\u0432\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 1 (\u0441\u0430\u043c\u043e\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435, \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f) \u0434\u043e 22 (\u0441\u0430\u043c\u0430\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f, \u0441\u0430\u043c\u043e\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435).<\/p>\n<h2>flate2  <\/h2>\n<p><code>flate2<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0431\u044d\u043a\u0435\u043d\u0434\u0430\u043c\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>miniz_oxide<\/code> \u0438 <code>zlib-ng<\/code>.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>read<\/code>: \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><code>write<\/code>: \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<\/li>\n<li>\n<p><code>bufread<\/code>: \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0447\u0442\u0435\u043d\u0438\u044f\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0422\u0438\u043f\u044b \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>GzEncoder<\/code> \u0438 <code>GzDecoder<\/code>: \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c gzip. <code>GzEncoder<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, <code>GzDecoder<\/code> \u2014 \u0434\u043b\u044f \u0438\u0445 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><code>DeflateEncoder<\/code> \u0438 <code>DeflateDecoder<\/code>: \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c DEFLATE.<\/p>\n<\/li>\n<li>\n<p><code>ZlibEncoder<\/code> \u0438 <code>ZlibDecoder<\/code>: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 zlib.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u044b<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>compress<\/code> \u0438 <code>decompress<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u041c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0438\u043b\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0437 \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><code>Compression<\/code>: \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0443\u0440\u043e\u0432\u043d\u0438 \u0441\u0436\u0430\u0442\u0438\u044f, \u043e\u0442 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0438 \u043c\u0435\u043d\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0434\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0433\u043e, \u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c DEFLATE<\/p>\n<pre><code class=\"rust\">use flate2::write::DeflateEncoder; use flate2::Compression; use std::io::prelude::*;  let data = b\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f\"; let mut encoder = DeflateEncoder::new(Vec::new(), Compression::default()); encoder.write_all(data).unwrap(); let compressed_data = encoder.finish().unwrap();<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 DEFLATE<\/p>\n<pre><code class=\"rust\">use flate2::read::DeflateDecoder; use std::io::prelude::*;  let mut decoder = DeflateDecoder::new(&amp;compressed_data[..]); let mut decompressed_data = Vec::new(); decoder.read_to_end(&amp;mut decompressed_data).unwrap();<\/code><\/pre>\n<p>\u042e\u0437\u0430\u0435\u043c gzip \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f<\/p>\n<pre><code class=\"rust\">use flate2::write::GzEncoder; use flate2::Compression; use std::io::prelude::*;  let mut encoder = GzEncoder::new(Vec::new(), Compression::fast()); encoder.write_all(b\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c gzip\").unwrap(); let gzip_compressed_data = encoder.finish().unwrap();<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 gzip<\/p>\n<pre><code class=\"rust\">use flate2::read::GzDecoder; use std::io::{self, Read};  let mut decoder = GzDecoder::new(&amp;gzip_compressed_data[..]); let mut decompressed_data = String::new(); decoder.read_to_string(&amp;mut decompressed_data).unwrap(); <\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0431\u044d\u043a\u0435\u043d\u0434 \u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442  \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<ul>\n<li>\n<p><strong>miniz_oxide<\/strong>: \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 Rust, \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0445 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>zlib-ng<\/strong>: \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u0438\u0431\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u0443\u043f\u0435\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"rust\">flate2 = { version = \"1.0.17\", features = [\"zlib-ng\"] }<\/code><\/pre>\n<h2>brotli  <\/h2>\n<p><code>brotli<\/code> \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u0441\u0430\u043c\u043e\u0439 Dropbox. \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f <em>\u043e\u0431\u0449\u0435\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445<\/em> \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438.  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<p><code>CompressorReader<\/code><strong> \u0438 <\/strong><code>CompressorWriter<\/code>: \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. <code>CompressorReader<\/code> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0430 <code>CompressorWriter<\/code> \u2014 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<p><code>Decompressor<\/code>: \u0434\u043b\u044f \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<p><code>encode<\/code><strong> \u0438 <\/strong><code>decode<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p><code>BrotliEncoderParams<\/code>: \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u043a\u043d\u0430.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u0432\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0438\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438.<\/p>\n<p><code>BrotliCompress<\/code><strong> \u0438 <\/strong><code>BrotliDecompress<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 <code>io::Read<\/code> \u0438 <code>io::Write<\/code>.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">use brotli::CompressorWriter; use std::io::Write;  let mut output = Vec::new(); {     let mut writer = CompressorWriter::new(&amp;mut output, 4096, 11, 22);     writer.write_all(b\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f\").unwrap(); }<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">use brotli::Decompressor; use std::io::Read;  let mut decompressor = Decompressor::new(&amp;output[..]); let mut result = String::new(); decompressor.read_to_string(&amp;mut result).unwrap();<\/code><\/pre>\n<h2>snap  <\/h2>\n<p>Snap \u043d\u0435 \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0441\u044f \u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u0436\u0430\u0442\u0438\u044e, \u0430 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c. <\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/strong><\/p>\n<p><code>FrameEncoder<\/code> \u0438 <code>FrameDecoder<\/code> &#8212; \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p><code>compress<\/code> \u0438 <code>decompress<\/code> \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p><code>compress_into<\/code> \u0438 <code>decompress_into<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0431\u0443\u0444\u0435\u0440.<\/p>\n<p><code>compress_raw<\/code> \u0438 <code>decompress_raw<\/code> \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430 &#171;<em>framed<\/em>&#171;<\/p>\n<p><code>compress_raw_into<\/code> \u0438 <code>decompress_raw_into<\/code> \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438, \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">extern crate snap;  use snap::{write::FrameEncoder, read::FrameDecoder}; use std::io::{Cursor, Read, Write};  let data = b\"Example data that needs to be compressed\"; let mut encoder = FrameEncoder::new(Vec::new()); encoder.write_all(data).unwrap(); let compressed = encoder.into_inner().unwrap();<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">let compressed_data = compressed; let mut decoder = FrameDecoder::new(Cursor::new(compressed_data)); let mut decompressed = Vec::new(); decoder.read_to_end(&amp;mut decompressed).unwrap();<\/code><\/pre>\n<p><code>snap<\/code> \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441\u0436\u0438\u043c\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0434\u043e 250 MB\/\u0441 \u0438 \u0431\u043e\u043b\u0435\u0435, \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0440\u0443\u044f \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0434\u043e 500 MB\/\u0441 \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445. <\/p>\n<h2>lz4-compression  <\/h2>\n<p><code>lz4-compression<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c LZ4. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u044f, \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0449\u0443\u044e \u0431\u043e\u043b\u0435\u0435 500 \u041c\u0411\/\u0441 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0413\u0411\/\u0441<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">use lz4::EncoderBuilder; use std::io::Write;  let mut encoder = EncoderBuilder::new().level(4).build(Vec::new()).unwrap(); encoder.write_all(b\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f\").unwrap(); let (compressed, result) = encoder.finish(); result.unwrap();<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">use lz4::Decoder; use std::io::Read;  let mut decoder = Decoder::new(&amp;compressed[..]).unwrap(); let mut decompressed = Vec::new(); decoder.read_to_end(&amp;mut decompressed).unwrap();<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0438\u043c\u0438\u043d\u0433\u043e\u0432\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f<\/p>\n<pre><code class=\"rust\">use lz4::EncoderBuilder; use lz4::Decoder; use std::io::{self, Read, Write, BufReader, BufWriter};  \/\/ \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u0442\u0440\u0438\u043c\u0438\u043d\u0433\u043e\u0432\u043e\u0433\u043e \u0441\u0436\u0430\u0442\u0438\u044f let input_stream = io::Cursor::new(b\"Data stream that needs to be compressed in real-time\"); let output_stream = Vec::new(); let mut encoder = EncoderBuilder::new().level(4).build(output_stream).unwrap(); let mut buffered_encoder = BufWriter::new(encoder);  \/\/ \u0441\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u0442\u0440\u0438\u043c\u0435 io::copy(&amp;mut BufReader::new(input_stream), &amp;mut buffered_encoder).unwrap(); let (compressed_stream, result) = buffered_encoder.into_inner().unwrap().finish(); result.unwrap();  \/\/ \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u0442\u0440\u0438\u043c\u0438\u043d\u0433\u043e\u0432\u043e\u0439 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 let input_compressed_stream = io::Cursor::new(compressed_stream); let mut decoder = Decoder::new(input_compressed_stream).unwrap(); let mut decompressed_stream = Vec::new();  \/\/ \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0441\u0442\u0440\u0438\u043c\u0430 decoder.read_to_end(&amp;mut decompressed_stream).unwrap();<\/code><\/pre>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0443\u0440\u043e\u0432\u043d\u0438 \u0441\u0436\u0430\u0442\u0438\u044f, \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0441\u0436\u0430\u0442\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 CPU, \u043d\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043b\u0443\u0447\u0448\u0435\u0435 \u0441\u0436\u0430\u0442\u0438\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f LZ4 \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0442\u044c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u043e 780 \u041c\u0411\/\u0441 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u043e 4970 \u041c\u0411\/\u0441, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a LZ4_HC \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0436\u0430\u0442\u0438\u044f, \u0441\u043d\u0438\u0436\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u043e 41 \u041c\u0411\/\u0441, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u043e\u0439.<\/p>\n<h4>\u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u0435 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c RUST<\/h4>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0436\u0430\u0442\u0438\u044f Run-Length Encoding.<\/p>\n<p>RLE \u2013 \u044d\u0442\u043e \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0436\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u043f\u0430\u0440\u044b &#171;\u0441\u0438\u043c\u0432\u043e\u043b-\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e&#187;.<\/p>\n<pre><code class=\"rust\">use std::char; use std::fmt::Write;  fn rle_encode(input: &amp;str) -> String {     let mut encoded = String::new();     let mut chars = input.chars();     let mut current_char = chars.next();      while let Some(c) = current_char {         let mut count = 1;          while let Some(next) = chars.next() {             if next == c {                 count += 1;             } else {                 break;             }         }          \/\/ \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b \u0438 \u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442         write!(&amp;mut encoded, \"{}{}\", c, count).unwrap();         current_char = chars.next();     }      encoded }  \/\/\/ \u044e\u0437\u0430\u0435\u043c fn main() {     let input_string = \"aaaabbbccddddde\";     let compressed = rle_encode(&amp;input_string);     println!(\"Original: {}\", input_string);     println!(\"Compressed: {}\", compressed); }<\/code><\/pre>\n<p><strong>rle_encode<\/strong>: \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0436\u0430\u0442\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p><strong>write!<\/strong>: \u043c\u0430\u043a\u0440\u043e\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0438 \u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 <code>encoded<\/code>.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0436\u0430\u0442\u044b, \u0438 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u0436\u0430\u0442\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<hr\/>\n<p>\u041a\u0430\u043a \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0434\u0430\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043a\u0430\u043a RLE \u0432\u044b\u0448\u043b\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a. <em>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/em><\/p>\n<p><strong>\u0410 \u043a\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Rust \u0437\u043d\u0430\u0435\u0442\u0435 \u0432\u044b?<\/strong> <em>\u0414\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445!<\/em><\/p>\n<p><em>\u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u0438\u0437 OTUS \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u043e\u0432. <\/em><a href=\"https:\/\/otus.pw\/EZka\/\"><em>\u041f\u043e \u0441\u0441\u044b\u043b\u043a\u0435<\/em><\/a><em> \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 <\/em><a href=\"https:\/\/otus.pw\/EZka\/\"><em>\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a <\/em><\/a><em>\u043a\u0443\u0440\u0441\u0430 &#171;\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432&#187;.<\/em><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/807431\/\"> https:\/\/habr.com\/ru\/articles\/807431\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p><strong>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/strong><\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u042f\u041f Rust. \u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043c\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u043b\u0438 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438. \u0420\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442 \u0434\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f: <em>\u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438<\/em> \u0438 <em>\u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c.<\/em><\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u0436\u0430\u0442\u0438\u044f \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u044c<\/strong><\/p>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432:<\/p>\n<ul>\n<li>\n<p><strong>\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u0434\u0435<\/strong>;<\/p>\n<\/li>\n<li>\n<p><strong>\u0410\u0440\u0445\u0438\u0432\u0430\u0446\u0438\u044f\u0445<\/strong>, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0436\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u0435\u0437 \u043f\u043e\u0442\u0435\u0440\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/strong>, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a PNG, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u0430\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 &#8212;  <strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0425\u0430\u0444\u0444\u043c\u0430\u043d\u0430<\/strong> \u0438 <strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u041b\u0435\u043c\u043f\u0435\u043b\u044f-\u0417\u0438\u0432\u0430-\u0412\u0435\u043b\u0447\u0430<\/strong>.<\/p>\n<p><strong>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u0436\u0430\u0442\u0438\u044f \u0441 \u043f\u043e\u0442\u0435\u0440\u044f\u043c\u0438<\/strong><\/p>\n<p>\u0410 \u0432\u043e\u0442 \u044d\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0442\u0430\u043c, \u0433\u0434\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u043e\u0442\u0435\u0440\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0432\u0430\u0436\u043d\u0430, \u043d\u043e \u0432\u0430\u0436\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p><strong>\u0412\u0438\u0434\u0435\u043e \u0438 \u0430\u0443\u0434\u0438\u043e<\/strong> \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u0433\u0434\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u043c\u0435\u0442\u043d\u044b \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0432\u0437\u0433\u043b\u044f\u0434\u0443 \u0438\u043b\u0438 \u0441\u043b\u0443\u0445\u0443;<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u0436\u0430\u0442\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/strong> \u0434\u043b\u044f \u0432\u0435\u0431\u0430, \u0433\u0434\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043e\u043c \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0441\u0443\u043f\u0435\u0440\u0441\u043a\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0434\u0438\u043d \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0442\u0430\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 &#8212; <strong>DCT<\/strong>.<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u043a\u0440\u0430\u0442\u043a\u043e \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043f\u0440\u043e \u043e\u0441\u043d\u043e\u0432\u044b, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c. \u0418 \u043f\u0435\u0440\u0432\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 &#8212; <strong>zstd<\/strong>.<\/p>\n<h2>zstd<\/h2>\n<p><code>zstd<\/code> \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435, \u0442\u0430\u043a \u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. <\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/strong><\/p>\n<p><code>encoder<\/code><strong> <\/strong>\u0438<strong> <\/strong><code>decoder<\/code> \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. <code>encoder<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a <code>decoder<\/code> \u0447\u0438\u0442\u0430\u0435\u0442 \u0441\u0436\u0430\u0442\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438\u0445.<\/p>\n<p><code>stream<\/code>: \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0440\u0438\u043c\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>copy_encode<\/code> \u0438 <code>copy_decode<\/code> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430 Rust.<\/p>\n<p><code>dict<\/code>: \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e \u0441\u043b\u043e\u0432\u0430\u0440\u044f\u043c\u0438 \u0441\u0436\u0430\u0442\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0436\u0438\u043c\u0430\u0435\u0442 \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u0436\u0438\u043c\u0430\u0442\u044c.<\/p>\n<p><code>encode_all<\/code> \u0438 <code>decode_all<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u043b\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p><code>compression_level_range<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0441\u0436\u0430\u0442\u0438\u044f.<\/p>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <code>async-compression<\/code> \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u0443\u0435\u0442 <code>zstd<\/code> \u0441 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 Rust, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<p><code>DEFAULT_COMPRESSION_LEVEL<\/code>: \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0430\u044f \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f<\/p>\n<pre><code class=\"rust\">use std::io; use zstd::stream::{read::Decoder, write::Encoder};  \/\/ \u0441\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 fn compress(data: &amp;[u8], level: i32) -> io::Result&lt;Vec&lt;u8>> {     let mut encoder = Encoder::new(Vec::new(), level)?;     io::copy(&amp;mut &amp;data[..], &amp;mut encoder)?;     let compressed = encoder.finish()?;     Ok(compressed) }  \/\/ \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 fn decompress(data: &amp;[u8]) -> io::Result&lt;Vec&lt;u8>> {     let mut decoder = Decoder::new(&amp;data[..])?;     let mut decompressed = Vec::new();     io::copy(&amp;mut decoder, &amp;mut decompressed)?;     Ok(decompressed) }<\/code><\/pre>\n<p>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f<\/p>\n<pre><code class=\"rust\">use async_compression::stream::{ZstdDecoder, ZstdEncoder}; use tokio::io::{self, AsyncReadExt, AsyncWriteExt};  async fn compress_async(input: &amp;[u8], level: i32) -> io::Result&lt;Vec&lt;u8>> {     let reader = io::Cursor::new(input);     let stream = ZstdEncoder::with_quality(reader, level);     let mut writer = Vec::new();     let mut stream = io::BufReader::new(stream);      while let Some(bytes) = stream.fill_buf().await? {         writer.write_all(bytes)?;         stream.consume(bytes.len());     }     Ok(writer) }  async fn decompress_async(input: &amp;[u8]) -> io::Result&lt;Vec&lt;u8>> {     let reader = io::Cursor::new(input);     let stream = ZstdDecoder::new(reader);     let mut writer = Vec::new();     let mut stream = io::BufReader::new(stream);      while let Some(bytes) = stream.fill_buf().await? {         writer.write_all(bytes)?;         stream.consume(bytes.len());     }     Ok(writer) }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0443\u0440\u043e\u0432\u043d\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>Encoder<\/code>. \u0423\u0440\u043e\u0432\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 1 (\u0441\u0430\u043c\u043e\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435, \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f) \u0434\u043e 22 (\u0441\u0430\u043c\u0430\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f, \u0441\u0430\u043c\u043e\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435).<\/p>\n<h2>flate2  <\/h2>\n<p><code>flate2<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0431\u044d\u043a\u0435\u043d\u0434\u0430\u043c\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f <code>miniz_oxide<\/code> \u0438 <code>zlib-ng<\/code>.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<ol>\n<li>\n<p><strong>\u041c\u043e\u0434\u0443\u043b\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>read<\/code>: \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><code>write<\/code>: \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<\/li>\n<li>\n<p><code>bufread<\/code>: \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0443\u0444\u0435\u0440\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0447\u0442\u0435\u043d\u0438\u044f\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0422\u0438\u043f\u044b \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>GzEncoder<\/code> \u0438 <code>GzDecoder<\/code>: \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c gzip. <code>GzEncoder<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, <code>GzDecoder<\/code> \u2014 \u0434\u043b\u044f \u0438\u0445 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p><code>DeflateEncoder<\/code> \u0438 <code>DeflateDecoder<\/code>: \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u043c DEFLATE.<\/p>\n<\/li>\n<li>\n<p><code>ZlibEncoder<\/code> \u0438 <code>ZlibDecoder<\/code>: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 zlib.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0443\u0442\u0438\u043b\u0438\u0442\u044b<\/strong>:<\/p>\n<ul>\n<li>\n<p><code>compress<\/code> \u0438 <code>decompress<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u041c\u043e\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0438\u043b\u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0437 \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><code>Compression<\/code>: \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0443\u0440\u043e\u0432\u043d\u0438 \u0441\u0436\u0430\u0442\u0438\u044f, \u043e\u0442 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0438 \u043c\u0435\u043d\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0434\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0433\u043e, \u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c DEFLATE<\/p>\n<pre><code class=\"rust\">use flate2::write::DeflateEncoder; use flate2::Compression; use std::io::prelude::*;  let data = b\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f\"; let mut encoder = DeflateEncoder::new(Vec::new(), Compression::default()); encoder.write_all(data).unwrap(); let compressed_data = encoder.finish().unwrap();<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 DEFLATE<\/p>\n<pre><code class=\"rust\">use flate2::read::DeflateDecoder; use std::io::prelude::*;  let mut decoder = DeflateDecoder::new(&amp;compressed_data[..]); let mut decompressed_data = Vec::new(); decoder.read_to_end(&amp;mut decompressed_data).unwrap();<\/code><\/pre>\n<p>\u042e\u0437\u0430\u0435\u043c gzip \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f<\/p>\n<pre><code class=\"rust\">use flate2::write::GzEncoder; use flate2::Compression; use std::io::prelude::*;  let mut encoder = GzEncoder::new(Vec::new(), Compression::fast()); encoder.write_all(b\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c gzip\").unwrap(); let gzip_compressed_data = encoder.finish().unwrap();<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 gzip<\/p>\n<pre><code class=\"rust\">use flate2::read::GzDecoder; use std::io::{self, Read};  let mut decoder = GzDecoder::new(&amp;gzip_compressed_data[..]); let mut decompressed_data = String::new(); decoder.read_to_string(&amp;mut decompressed_data).unwrap(); <\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0431\u044d\u043a\u0435\u043d\u0434 \u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442  \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<ul>\n<li>\n<p><strong>miniz_oxide<\/strong>: \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0430 Rust, \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0445 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>zlib-ng<\/strong>: \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u0438\u0431\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0441\u0443\u043f\u0435\u0440 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438:<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"rust\">flate2 = { version = \"1.0.17\", features = [\"zlib-ng\"] }<\/code><\/pre>\n<h2>brotli  <\/h2>\n<p><code>brotli<\/code> \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u0441\u0430\u043c\u043e\u0439 Dropbox. \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0434\u043b\u044f <em>\u043e\u0431\u0449\u0435\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445<\/em> \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438.  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<p><code>CompressorReader<\/code><strong> \u0438 <\/strong><code>CompressorWriter<\/code>: \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0441\u0436\u0430\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. <code>CompressorReader<\/code> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435, \u0430 <code>CompressorWriter<\/code> \u2014 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<p><code>Decompressor<\/code>: \u0434\u043b\u044f \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c.<\/p>\n<p><code>encode<\/code><strong> \u0438 <\/strong><code>decode<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p><code>BrotliEncoderParams<\/code>: \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0441\u0436\u0430\u0442\u0438\u044f, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u043a\u043d\u0430.<\/p>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u0432\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0438\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438.<\/p>\n<p><code>BrotliCompress<\/code><strong> \u0438 <\/strong><code>BrotliDecompress<\/code>: \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 <code>io::Read<\/code> \u0438 <code>io::Write<\/code>.<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">use brotli::CompressorWriter; use std::io::Write;  let mut output = Vec::new(); {     let mut writer = CompressorWriter::new(&amp;mut output, 4096, 11, 22);     writer.write_all(b\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f\").unwrap(); }<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">use brotli::Decompressor; use std::io::Read;  let mut decompressor = Decompressor::new(&amp;output[..]); let mut result = String::new(); decompressor.read_to_string(&amp;mut result).unwrap();<\/code><\/pre>\n<h2>snap  <\/h2>\n<p>Snap \u043d\u0435 \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0441\u044f \u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u0436\u0430\u0442\u0438\u044e, \u0430 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c. <\/p>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/strong><\/p>\n<p><code>FrameEncoder<\/code> \u0438 <code>FrameDecoder<\/code> &#8212; \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p><code>compress<\/code> \u0438 <code>decompress<\/code> \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p><code>compress_into<\/code> \u0438 <code>decompress_into<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0441\u0436\u0438\u043c\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0431\u0443\u0444\u0435\u0440.<\/p>\n<p><code>compress_raw<\/code> \u0438 <code>decompress_raw<\/code> \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0430\u0442\u0430 &#171;<em>framed<\/em>&#171;<\/p>\n<p><code>compress_raw_into<\/code> \u0438 <code>decompress_raw_into<\/code> \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u0431\u0443\u0444\u0435\u0440\u0430\u043c\u0438, \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">extern crate snap;  use snap::{write::FrameEncoder, read::FrameDecoder}; use std::io::{Cursor, Read, Write};  let data = b\"Example data that needs to be compressed\"; let mut encoder = FrameEncoder::new(Vec::new()); encoder.write_all(data).unwrap(); let compressed = encoder.into_inner().unwrap();<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">let compressed_data = compressed; let mut decoder = FrameDecoder::new(Cursor::new(compressed_data)); let mut decompressed = Vec::new(); decoder.read_to_end(&amp;mut decompressed).unwrap();<\/code><\/pre>\n<p><code>snap<\/code> \u0441\u0435\u0439\u0447\u0430\u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441\u0436\u0438\u043c\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0434\u043e 250 MB\/\u0441 \u0438 \u0431\u043e\u043b\u0435\u0435, \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0440\u0443\u044f \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0434\u043e 500 MB\/\u0441 \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u0445. <\/p>\n<h2>lz4-compression  <\/h2>\n<p><code>lz4-compression<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c LZ4. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u0436\u0430\u0442\u0438\u044f, \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0449\u0443\u044e \u0431\u043e\u043b\u0435\u0435 500 \u041c\u0411\/\u0441 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u044f\u0434\u0440\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0413\u0411\/\u0441<\/p>\n<h4>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h4>\n<p>\u0421\u0436\u0430\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">use lz4::EncoderBuilder; use std::io::Write;  let mut encoder = EncoderBuilder::new().level(4).build(Vec::new()).unwrap(); encoder.write_all(b\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0441\u0436\u0430\u0442\u0438\u044f\").unwrap(); let (compressed, result) = encoder.finish(); result.unwrap();<\/code><\/pre>\n<p>\u0414\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"rust\">use lz4::Decoder; use std::io::Read;  let mut decoder = Decoder::new(&amp;compressed[..]).unwrap(); let mut decompressed = Vec::new(); decoder.read_to_end(&amp;mut decompressed).unwrap();<\/code><\/pre>\n<p>\u0421\u0442\u0440\u0438\u043c\u0438\u043d\u0433\u043e\u0432\u043e\u0435 \u0441\u0436\u0430\u0442\u0438\u0435 \u0438 \u0434\u0435\u043a\u043e\u043c\u043f\u0440\u0435\u0441\u0441\u0438\u044f<\/p>\n<pre><code class=\"rust\">use lz4::EncoderBuilder;<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-373517","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/373517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=373517"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/373517\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}