{"id":285177,"date":"2017-04-19T02:45:29","date_gmt":"2017-04-18T22:45:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=285177"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=285177","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c Telegram \u0431\u043e\u0442\u0430 \u043d\u0430 Rust, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430&#8230;Rust?"},"content":{"rendered":"<p>\u0414\u043e\u0431\u0440\u043e\u0439 \u043d\u043e\u0447\u0438! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043a\u0440\u0430\u0442\u043a\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c Telegram \u0431\u043e\u0442\u0430 \u043d\u0430 Rust, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 Rust. \u0423 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435\u0442 \u0446\u0435\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 API telegram_bot, Serde, Telegram \u0438\u043b\u0438 \u0432 \u043d\u044e\u0430\u043d\u0441\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 Rust. \u041e\u043d\u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u043d\u043e\u0441\u0438\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440. \u0427\u0438\u0441\u043b\u0430 \u041f\u0435\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e1d\/a90\/000\/e1da900003684042a932bb58d714ea01.png\" alt=\"\u041f\u0440\u0435\u0432\u044c\u044e \u043a \u0441\u0442\u0430\u0442\u044c\u0435\"\/><\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h1 id=\"sozdanie-bota-v-telegram\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0431\u043e\u0442\u0430 \u0432 Telegram<\/h1>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u043e\u0442\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c HTTP API \u0442\u043e\u043a\u0435\u043d:<\/p>\n<p>  <\/p>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u043c \u043a \u044d\u0442\u043e\u043c\u0443 \u043f\u0430\u0440\u043d\u044e <a href=\"https:\/\/web.telegram.org\/#\/im?p=@BotFather\">Bot Father<\/a> \u0438 \u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0438\u0446\u0438\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430: <code>\/newbot<\/code>.<br \/>  \u041e\u0442\u0432\u0435\u0442 \u043a\u0440\u0451\u0441\u0442\u043d\u043e\u0433\u043e \u043e\u0442\u0446\u0430:<\/p>\n<p>  <\/p>\n<pre><code>Alright, a new bot. How are we going to call it? Please choose a name for your bot. <\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043e\u0442\u0432\u0435\u0442\u0435 \u043f\u0438\u0448\u0435\u043c \u0438\u043c\u044f \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c: <code>rust<\/code>.<br \/>  \u041e\u0442\u0432\u0435\u0442 \u043a\u0440\u0451\u0441\u0442\u043d\u043e\u0433\u043e \u043e\u0442\u0446\u0430:<\/p>\n<p>  <\/p>\n<pre><code>Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot. <\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f\u043c \u0432\u0432\u043e\u0434\u0438\u043c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0438\u043c\u044f <code>rustlanguage_bot<\/code>.<br \/>  \u041e\u0442\u0432\u0435\u0442 \u043a\u0440\u0451\u0441\u0442\u043d\u043e\u0433\u043e \u043e\u0442\u0446\u0430:<\/p>\n<p>  <\/p>\n<pre><code>Done! Congratulations on your new bot. You will find it at t.me\/rustlanguage_bot. You can now add a description, about section and profile picture for your bot, see \/help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.  Use this token to access the HTTP API: %TOKEN%  For a description of the Bot API, see this page: https:\/\/core.telegram.org\/bots\/api <\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0411\u043e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d. <code>%TOKEN%<\/code> \u2014 \u044d\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0435\u0441\u0442\u044c \u0442\u043e\u043a\u0435\u043d.<\/p>\n<p>  <\/p>\n<h1 id=\"rust-playground\">Rust Playground<\/h1>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u043e \u0442\u043e\u043c, \u043a\u0430\u043a, \u0438 \u0433\u0434\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u0442\u0443 \u0432 \u0432\u0438\u0434\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 <code>Rust Playground<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 Rust \u043a\u043e\u0434 \u043e\u043d\u043b\u0430\u0439\u043d. \u0418\u043c \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f. \u0420\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043e\u043d \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443: <a href=\"https:\/\/play.rust-lang.org\/\">https:\/\/play.rust-lang.org\/<\/a><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e hello-world \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     println!(&quot;Hello world!&quot;); } <\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <code>Network<\/code> \u0438\u0437 <code>DevTools<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0447\u0442\u043e \u0438 \u0432 \u043a\u0430\u043a\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u043e\u043d \u0448\u043b\u0451\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/059\/598\/a6b\/059598a6b37c4781b53ea79f13a04dfc.png\" alt=\"Rust Playground Request\"\/><\/p>\n<p>  <\/p>\n<p>\u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u0432\u0441\u0451 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0438\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u0438:<\/p>\n<p>  <\/p>\n<pre><code>[loomaclin@localhost ~]$ curl -X POST -d '{&quot;code&quot;:&quot;fn main() {\\n    println!(\\&quot;Hello world!\\&quot;);\\n}&quot;,&quot;version&quot;:&quot;stable&quot;,&quot;optimize&quot;:&quot;0&quot;,&quot;test&quot;:false,&quot;separate_output&quot;:true,&quot;color&quot;:true,&quot;backtrace&quot;:&quot;0&quot;}' https:\/\/play.rust-lang.org\/evaluate.json {&quot;program&quot;:&quot;Hello world!\\n&quot;,&quot;rustc&quot;:&quot;rustc 1.16.0 (30cf806ef 2017-03-10)\\n&quot;} <\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u043e\u0435\u0445\u0430\u043b\u0438 \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>  <\/p>\n<h1 id=\"pishem-bota\">\u041f\u0438\u0448\u0435\u043c \u0431\u043e\u0442\u0430<\/h1>\n<p>  <\/p>\n<h4 id=\"sozdayom-proekt\">\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442.<\/h4>\n<p>  <\/p>\n<pre><code>cargo new rust_telegram_bot --bin<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"dobavim-sleduyuschie-zavisimosti-v-cargotoml\">\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 <code>Cargo.toml<\/code>:<\/h4>\n<p>  <\/p>\n<pre><code>[dependencies] telegram-bot = { git = &quot;https:\/\/github.com\/White-Oak\/telegram-bot.git&quot; } hyper = &quot;0.10.8&quot; hyper-rustls = &quot;0.3.2&quot; serde_json = &quot;0.9.10&quot; serde = &quot;0.9.14&quot; serde_derive = &quot;0.9.14&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0440\u0430\u0442\u043a\u043e \u043e\u043f\u0438\u0448\u0443 \u0437\u0430\u0447\u0435\u043c \u043e\u043d\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\n<p><code>Serde<\/code> \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0430 \u0434\u043b\u044f \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\/\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u0430\u0445. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 JSON (serde_json) \u0438 \u0449\u0435\u043f\u043e\u0442\u043a\u0430 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 (serde_derive);<\/p>\n<p>  <\/li>\n<li>\n<p><code>Hyper<\/code> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0435\u0442\u044c\u044e, \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c HTTP-\u043a\u043b\u0438\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 Rust Playground, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 HTTPS \u0435\u0449\u0451 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0431\u0430\u0442\u0430\u0440\u0435\u0439\u043a\u0430 \u0432 \u0432\u0438\u0434\u0435 <code>hyper-rustls<\/code>;<\/p>\n<p>  <\/li>\n<li>\u043d\u0443 \u0438 \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 Telegram API \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>telegram-bot<\/code>, \u043d\u043e \u043d\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0435\u0451, \u0430 \u0444\u043e\u0440\u043a \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0430 @white_oak, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043e\u0433\u043d\u0430\u043b \u0435\u0451 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 <code>Hyper<\/code> \u0437\u0430 \u0447\u0442\u043e \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0435\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u043e\u0435.<\/li>\n<\/ul>\n<p>  <\/p>\n<h4 id=\"v-srcmainrs-podklyuchim-vse-neobhodimye-biblioteki-i-moduli\">\u0412 <code>src\/main.rs<\/code> \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043c\u043e\u0434\u0443\u043b\u0438:<\/h4>\n<p>  <\/p>\n<pre><code class=\"rust\">extern crate telegram_bot; extern crate hyper; extern crate hyper_rustls; extern crate serde_json; extern crate serde; #[macro_use] extern crate serde_derive;  use serde_json::Value; use telegram_bot::*; use std::io::Read; use hyper::client::Client; use hyper::net::HttpsConnector; use hyper_rustls::TlsClient;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: <code>#[macro_use]<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u044b\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442. <code>use telegram_bot::*<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0438\u0437 \u043a\u043e\u0440\u043d\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>  <\/p>\n<h4 id=\"opishem-s-pomoschyu-enum-vozmozhnye-vidy-otvetov-ot-servera-a-ih-v-dannom-sluchae-2-kogda-programma-byla-skompilirovanna-uspeshno-i-kogda-proizoshla-oshibka-kompilyacii\">\u041e\u043f\u0438\u0448\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>enum<\/code> \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0438\u0434\u044b \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0430 \u0438\u0445 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 2, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u044b\u043b\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0438 \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438:<\/h4>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Serialize, Deserialize, Debug)] #[serde(untagged)] pub enum ResponseType {     ProgramCompiled { program: String, rustc: String },     ProgramCompileError { rustc: String } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>#[serde(untagged)]<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u0440\u0438\u043c\u0435\u043d\u0451\u043d \u043a \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044e? \u041e\u043d \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 (\u0434\u0435)\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0442\u044d\u0433 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a\u0438\u043c \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u0422\u0430\u043a \u043a\u0430\u043a \u0436\u0435 <code>Serde<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442 \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438? \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438: <a href=\"https:\/\/serde.rs\/enum-representations.html\">https:\/\/serde.rs\/enum-representations.html<\/a>.<\/p>\n<p>  <\/p>\n<h4 id=\"opredelim-strukturu-strukturu-dlya-nashego-zaprosa-v-rust-playground\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 Rust Playground:<\/h4>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Serialize)] pub struct PlaygroundRequest {     code: String,     version: String,     optimize: String,     test: bool,     separate_output: bool,     color: bool,     backtrace: String }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430 \u0432 \u044d\u0442\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u043e\u0439\u0434\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435 <code>code<\/code>. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0438\u043c \u0438\u0431\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0435\u043c \ud83d\ude42 (\u043d\u0435\u0442)<\/p>\n<p>  <\/p>\n<h4 id=\"v-glavnoy-funkcii-programmy-main-sozdadim-instans-telegram-api-i-zastavim-ego-pechatat-vsyo-chto-prishlo-botu-v-soobscheniya\">\u0412 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <code>main<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0441 Telegram API \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0432\u0441\u0451 \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u043b\u043e \u0431\u043e\u0442\u0443 \u0432 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/h4>\n<p>  <\/p>\n<pre><code class=\"rust\">fn main() {     let api = Api::from_env(&quot;TOKEN&quot;).unwrap();     println!(&quot;getMe: {:?}&quot;, api.get_me());     let mut listener = api.listener(ListeningMethod::LongPoll(None));      let res = listener.listen(|u| if let Some(m) = u.message {                                   let name = m.from.first_name;                                   match m.msg {                                       MessageType::Text(t) =&gt; {                                             println!(&quot;&lt;{}&gt; {}&quot;, name, t);                                         }                                       _ =&gt; {}                                   }                               }); }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435:<\/p>\n<p>  <\/p>\n<pre><code>TOKEN=%TOKEN% cargo run<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435. <\/p>\n<p>  <\/p>\n<pre><code class=\"rust\"> let api = Api::from_env(&quot;TOKEN&quot;).unwrap();     println!(&quot;getMe: {:?}&quot;, api.get_me());<\/code><\/pre>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b <code>Api<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u0437 <code>telegram_bot<\/code>, \u0434\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044c \u0431\u043e\u0442\u0430 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 long-polling: <\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">let mut listener = api.listener(ListeningMethod::LongPoll(None));<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434 \u043a\u043e\u043d\u0435\u0446 \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0446\u0438\u043a\u043b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>listen<\/code> \u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u0442\u0438\u043f\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code>    let res = listener.listen(|u| if let Some(m) = u.message {                                   let name = m.from.first_name;                                   match m.msg {                                       MessageType::Text(t) =&gt; {                                             println!(&quot;&lt;{}&gt; {}&quot;, name, t);                                         }                                       _ =&gt; {}                                   }                               });<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u0434 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435, \u0444\u0430\u0439\u043b\u044b \u0438 \u043f\u0440\u043e\u0447\u0435\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u043c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u043a<br \/>  \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f <code>MessageType<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<h4 id=\"obrabatyvaem-komandu-rust-otpravlyaya-zapros-na-rust-playground-i-schityvaem-otvet\">\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>\/rust<\/code> \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 Rust Playground \u0438 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442:<\/h4>\n<p>  <\/p>\n<pre><code>    if t.starts_with(&quot;\/rust &quot;) {         let program = t.split(&quot;\/rust &quot;).collect();         let mut result = String::new();         let tls = hyper_rustls::TlsClient::new();         let connector = HttpsConnector::new(tls);         let client = Client::with_connector(connector);         let playground_request = serde_json::to_string(&amp;PlaygroundRequest {                                                             code: program,                                                             version: String::from(&quot;stable&quot;),                                                             optimize: String::from(&quot;0&quot;),                                                             test: false,                                                             separate_output: true,                                                             color: false,                                                             backtrace: String::from(&quot;0&quot;),                                                         })                 .unwrap();         let mut response = client             .post(&quot;https:\/\/play.rust-lang.org\/evaluate.json&quot;)             .body(&amp;playground_request)             .send()             .unwrap();         response.read_to_string(&amp;mut result);         println!(&quot;Result : {:?}&quot;, result);     }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b (<code>\/rust<\/code>):<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">if t.starts_with(&quot;\/rust &quot;) {<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0442\u0430\u043a \u0436\u0435 \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\"> let program = t.split(&quot;\/rust &quot;).collect();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>serde_json::to_string(&amp;PlaygroundReques { ... })<\/code> \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043d\u0430\u0448\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 HTTPS \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c: <a href=\"https:\/\/hyper.rs\/hyper\/v0.10.7\/hyper\/index.html\">https:\/\/hyper.rs\/hyper\/v0.10.7\/hyper\/index.html<\/a>.<\/p>\n<p>  <\/p>\n<h4 id=\"obrabatyvaem-prishedshiy-otvet\">\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0439 \u043e\u0442\u0432\u0435\u0442<\/h4>\n<p>  <\/p>\n<pre><code class=\"rust\">  let result : ResponseType = serde_json::from_str(&amp;result)                             .unwrap_or(ResponseType::ProgramCompileError {     rustc: String::from(&quot;\u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c&quot;)  });     let mut result = match result {         ResponseType::ProgramCompiled { program, .. } =&gt; {             format!(&quot;\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e: {}&quot;,                     program)         }         ResponseType::ProgramCompileError { rustc, .. } =&gt; {             format!(&quot;\u041e\u0448\u0438\u0431\u043a\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b: {}&quot;,                     rustc)         }     };<\/code><\/pre>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>serde::from_str<\/code> \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0439 \u043e\u0442\u0432\u0435\u0442 \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e <code>enum<\/code>, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043e\u0442\u0432\u0435\u0442 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043c\u044b \u0437\u0430\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u044d\u0442\u043e \u0432 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0441\u043b\u0430\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u0442\u043e\u043c, \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 <code>enum<\/code> \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u0438 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0432\u0438\u0434\u0430 <code>{ program, .. }<\/code>, \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u044d\u0442\u043e \u043e\u043f\u0443\u0441\u043a\u0430\u043d\u0438\u0435 \u0438\u0437 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0432 \u0445\u043e\u0434\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430.<\/p>\n<p>  <\/p>\n<h4 id=\"otpravka-rezultatov-kompilyacii-v-chat\">\u041e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432 \u0447\u0430\u0442<\/h4>\n<p>  <\/p>\n<pre><code class=\"rust\">    if result.len() &gt; 500 {         result.truncate(500);     }     try!(api.send_message(m.chat.id(), result, None, None, Some(m.message_id), None));<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u043b\u0438\u043d\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u0438 \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u044d\u0442\u043e \u0434\u0435\u043b\u043e. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0447\u0430\u0442\u0430 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438\u0448\u0435\u043b \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b \u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0432\u044b\u0432\u043e\u0434 \u043f\u0440\u0435\u0432\u044c\u044e, \u0432\u0438\u0434 \u043e\u0442\u0432\u0435\u0442\u0430 \u0438 \u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435.<\/p>\n<p>  <\/p>\n<h1 id=\"proveryaem-rabotosposobnost\">\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c<\/h1>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/09d\/87e\/463\/09d87e463f4348589fe7199cc334496b.png\" alt=\"\u0427\u0430\u0442 \u0441 rust \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0431\u043e\u0442\u043e\u043c\"\/><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:<\/p>\n<p>  <\/p>\n<pre><code>    Finished dev [unoptimized + debuginfo] target(s) in 2.38 secs      Running `target\/debug\/rust_telegram_bot` getMe: Ok(User { id: 334562900, first_name: &quot;rust&quot;, last_name: None, username: Some(&quot;rustlanguage_bot&quot;) }) &lt;Arsen&gt; \/rust abc Result : &quot;{\\&quot;rustc\\&quot;:\\&quot;rustc 1.16.0 (30cf806ef 2017-03-10)\\\\nerror: expected one of `!` or `::`, found `&lt;eof&gt;`\\\\n --&gt; &lt;anon&gt;:1:1\\\\n  |\\\\n1 | abc\\\\n  | ^^^\\\\n\\\\nerror: aborting due to previous error\\\\n\\\\n\\&quot;}&quot; &lt;Arsen&gt; \/rust fn main() { println!(&quot;Hello habrahabr!&quot;); } Result : &quot;{\\&quot;program\\&quot;:\\&quot;Hello habrahabr!\\\\n\\&quot;,\\&quot;rustc\\&quot;:\\&quot;rustc 1.16.0 (30cf806ef 2017-03-10)\\\\n\\&quot;}&quot;<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0414\u0443\u043c\u0430\u044e \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451. \u0421\u043f\u0430\u0441\u0438\u0431\u043e <a href=\"https:\/\/github.com\/White-Oak\">WhiteOak<\/a> \u0437\u0430 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0444\u043e\u0440\u043a <code>telegram_bot<\/code>.<br \/>  \u041a\u0441\u0442\u0430\u0442\u0438 \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u043e\u0432 \u043a QML \u0438\u0437 Rust: <a href=\"https:\/\/github.com\/White-Oak\/qml-rust\">https:\/\/github.com\/White-Oak\/qml-rust<\/a> \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0443 \u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c. \u041b\u044e\u0431\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u043a\u0440\u0438\u0442\u0438\u043a\u0430 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/github.com\/LooMaclin\/rust_telegram_bot\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p> \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:\/\/habrahabr.ru\/post\/326830\/\"> https:\/\/habrahabr.ru\/post\/326830\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u043e\u0431\u0440\u043e\u0439 \u043d\u043e\u0447\u0438! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043a\u0440\u0430\u0442\u043a\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c Telegram \u0431\u043e\u0442\u0430 \u043d\u0430 Rust, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u0434 \u043d\u0430 Rust. \u0423 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435\u0442 \u0446\u0435\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u043b\u043d\u043e\u0435 \u043f\u043e\u0433\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432 API telegram_bot, Serde, Telegram \u0438\u043b\u0438 \u0432 \u043d\u044e\u0430\u043d\u0441\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 Rust. \u041e\u043d\u0430 \u0441\u043a\u043e\u0440\u0435\u0435 \u043d\u043e\u0441\u0438\u0442 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440. \u0427\u0438\u0441\u043b\u0430 \u041f\u0435\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e1d\/a90\/000\/e1da900003684042a932bb58d714ea01.png\" alt=\"\u041f\u0440\u0435\u0432\u044c\u044e \u043a \u0441\u0442\u0430\u0442\u044c\u0435\"\/><\/p>\n<p>  <\/p>\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-285177","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285177","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=285177"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/285177\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=285177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=285177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=285177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}