{"id":298138,"date":"2020-02-03T15:00:35","date_gmt":"2020-02-03T15:00:35","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298138"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298138","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c API \u043d\u0430 Rust \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486740\/\">\n<p>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0432 Rust \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u043e\u043d\u043d\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0438\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043b\u0438, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043a\u0440\u0435\u0439\u0442\u0430 <a href=\"https:\/\/docs.rs\/async-trait\/0.1.22\/async_trait\/\" rel=\"nofollow\"><code>async_trait<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u043e\u0431\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0440\u0430\u0437\u0431\u043e\u0440 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 &quot;\u0437\u0430\u043a\u0430\u0442 \u0441\u043e\u043b\u043d\u0446\u0430 \u0432\u0440\u0443\u0447\u043d\u0443\u044e&quot;, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0430\u0442\u044c \u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0443\u0434\u0430\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438 \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2 id=\"predislovie\">\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0448\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432: \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Remote_procedure_call\" rel=\"nofollow\">RPC<\/a> API \u0432 \u0432\u0438\u0434\u0435 \u0442\u0440\u0435\u0439\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043a\u0430\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c, \u0442\u0430\u043a \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f; \u0430 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043d\u0430\u043c \u0431\u0435\u0437 \u043a\u0443\u0447\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 API, \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u0430\u044f, \u0438, \u043f\u043e\u043c\u0438\u043c\u043e \u043f\u0440\u043e\u0447\u0435\u0433\u043e, \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0421\u0430\u043c API \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d \u043f\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443: \u0435\u0441\u0442\u044c 4 \u0442\u0438\u043f\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li>GET \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>\/ping<\/code>.<\/li>\n<li>GET \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 URL query, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: <code>\/status?name=foo&amp;count=15<\/code>.<\/li>\n<li>POST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/li>\n<li>POST \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 JSON \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u043e \u0432\u0441\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c JSON \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u0431\u044d\u043a\u0435\u043d\u0434\u0430 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0435\u0439\u0442 <a href=\"https:\/\/docs.rs\/warp\/0.2.1\/warp\/\" rel=\"nofollow\"><code>warp<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:  \/\/\/ \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0430\u044f \u0432\u0438\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0438\u0437 URL query, \u0442\u0430\u043a \u0438 \u0438\u0437 JSON. #[derive(Debug, FromUrlQuery, Deserialize, Serialize)] struct Query {     first: String,     second: u64, }  \/\/\/ \u0421\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c\u0441\u044f \/\/\/ \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 API \u043f\u043e\u0432\u0435\u0440\u0445 warp'\u0430. #[http_api(warp = &quot;serve_ping_interface&quot;)] trait PingInterface {     #[http_api_endpoint(method = &quot;get&quot;)]     fn get(&amp;self) -&gt; Result&lt;Query, Error&gt;;     #[http_api_endpoint(method = &quot;get&quot;)]     fn check(&amp;self, query: Query) -&gt; Result&lt;bool, Error&gt;;     #[http_api_endpoint(method = &quot;post&quot;)]     fn set_value(&amp;self, param: Query) -&gt; Result&lt;(), Error&gt;;     #[http_api_endpoint(method = &quot;post&quot;)]     fn increment(&amp;self) -&gt; Result&lt;(), Error&gt;; }  \/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:  \/\/\/ \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430. #[derive(Debug, Default)] struct ServiceInner {     first: String,     second: u64, }  \/\/\/ \u0421\u0430\u043c \u0441\u0435\u0440\u0432\u0438\u0441, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. #[derive(Clone, Default)] struct ServiceImpl(Arc&lt;RwLock&lt;ServiceInner&gt;&gt;);  impl ServiceImpl {     fn new() -&gt; Self {         Self::default()     }      fn read(&amp;self) -&gt; RwLockReadGuard&lt;ServiceInner&gt; {         self.0.read().unwrap()     }      fn write(&amp;self) -&gt; RwLockWriteGuard&lt;ServiceInner&gt; {         self.0.write().unwrap()     } }  \/\/ \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430:  impl PingInterface for ServiceImpl {     fn get(&amp;self) -&gt; Result&lt;Query, Error&gt; {         let inner = self.read();         Ok(Query {             first: inner.first.clone(),             second: inner.second,         })     }      fn check(&amp;self, query: Query) -&gt; Result&lt;bool, Error&gt; {         let inner = self.read();         Ok(inner.first == query.first &amp;&amp; inner.second == query.second)     }      fn set_value(&amp;self, param: Query) -&gt; Result&lt;(), Error&gt; {         let mut inner = self.write();         inner.first = param.first;         inner.second = param.second;         Ok(())     }      fn increment(&amp;self) -&gt; Result&lt;(), Error&gt; {         self.write().second += 1;         Ok(())     } }  #[tokio::main] async fn main() {     let addr: SocketAddr = &quot;127.0.0.1:8080&quot;.parse().unwrap();     \/\/ \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 \u043d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c API     serve_ping_interface(ServiceImpl::new(), addr).await }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u043c\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u043c\u0438 \u0432 Rust&#8217;\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u044b \u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<br \/>  \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0442\u0430\u043a\u0438\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432: derive-\u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0435\u0439\u0442 \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b (\u043c\u043d\u043e\u0433\u0438\u043c \u043e\u043d\u0438 \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u043f\u043e <a href=\"https:\/\/serde.rs\/\" rel=\"nofollow\"><code>serde<\/code><\/a>), \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0441\u043f\u0435\u043a\u0442\u0440\u0430 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u043c\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u043e\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u0440\u0435\u0439\u0442\u043e\u0432, \u0442\u043e \u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430 \u0434\u0432\u0430 \u043a\u0440\u0435\u0439\u0442\u0430: <code>http_api<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0442\u0440\u0435\u0439\u0442\u044b \u0438 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0438 <code>http_api_derive<\/code> \u0441 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u043c\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"sozdaem-makros-fromurlquery\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441 FromUrlQuery<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0441\u0430\u043c\u044b\u0439 \u0438\u0434\u0438\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0435\u0433\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432 \u0434\u0435\u0440\u0430\u0439\u0432-\u043c\u0430\u043a\u0440\u043e\u0441\u0430\u0445 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043a\u043e\u0434, \u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0445 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u0434\u043e\u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044e.<\/p>\n<p>  <\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043d\u0430\u0448 \u0442\u0440\u0435\u0439\u0442 \u043f\u043e \u0440\u0430\u0437\u0431\u043e\u0440\u0443 URL query. \u0414\u0430\u043d\u043d\u044b\u0439 \u0442\u0440\u0435\u0439\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u0437 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044d\u0442\u043e\u0442 \u0442\u0440\u0435\u0439\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub trait FromUrlQuery: Sized {     fn from_query_str(query: &amp;str) -&gt; Result&lt;Self, ParseQueryError&gt;; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0442\u0440\u0435\u0439\u0442, \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441. \u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0442\u0438\u043f\u0443 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 derive \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/\/ \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u0430\u043a\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 `#[derive(FromUrlQuery)]`, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \/\/\/ \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c \u0442\u0438\u043f\u0430 #[from_url_query(rename = &quot;bar&quot;, skip, etc)] #[proc_macro_derive(FromUrlQuery, attributes(from_url_query))] pub fn from_url_query(input: TokenStream) -&gt; TokenStream {     from_url_query::impl_from_url_query(input) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u0436\u0435\u043d\u0442\u043b\u044c\u043c\u0435\u043d\u0441\u043a\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u2014 \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/docs.rs\/syn\/1.0.14\/syn\/\" rel=\"nofollow\"><code>syn<\/code><\/a>, <a href=\"https:\/\/docs.rs\/quote\/1.0.2\/quote\/\" rel=\"nofollow\"><code>quote<\/code><\/a>. \u041f\u0435\u0440\u0432\u044b\u0439 \u043a\u0440\u0435\u0439\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0441\u0435\u0440\u043e\u043c <code>Rust<\/code> \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u0435 \u0442\u0438\u043f\u044b \u0442\u043e\u043a\u0435\u043d\u043e\u0432, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435.<br \/>  \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043a\u0440\u0435\u0439\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 <a href=\"https:\/\/docs.rs\/quote\/1.0.2\/quote\/macro.quote.html\" rel=\"nofollow\"><code>quote!<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0441\u0443\u0442\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 Rust \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<br \/>  \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043a\u0440\u0435\u0439\u0442\u043e\u0432, \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u044f\u0434, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"https:\/\/docs.rs\/darling\/0.10.2\/darling\/\" rel=\"nofollow\"><code>darling<\/code><\/a>. \u042d\u0442\u043e\u0442 \u043a\u0440\u0435\u0439\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0431\u043e\u0440 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u0442\u0440\u0435\u0439\u0442\u043e\u0432 \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u043f\u043e \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0438\u043b\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 (\u0442\u043e \u0435\u0441\u0442\u044c, \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0430).<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u0448\u043d\u044b\u0439 \u043a\u043e\u0434, \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b **\u043d\u0435 \u0431\u0443\u0434\u0435\u043c**. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0438 \u043f\u0440\u043e\u043d\u0438\u043a\u043d\u0435\u0442\u0435\u0441\u044c \u044d\u043a\u0437\u0438\u0441\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0443\u0436\u0430\u0441\u043e\u043c:<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041e\u0431\u044b\u0447\u043d\u043e \u043a\u043e\u0434 \u0440\u0430\u0437\u0431\u043e\u0440\u0430 AST \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0448\u043c\u0430\u0440, \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0449\u0438\u0439 \u043a\u0430\u043a \u043a\u0443\u0447\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439, \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0440\u0430\u0439\u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn get_field_names(input: &amp;DeriveInput) -&gt; Option&lt;Vec&lt;(Ident, Action)&gt;&gt; {     let data = match &amp;input.data {         Data::Struct(x) =&gt; Some(x),         Data::Enum(..) =&gt; None,         _ =&gt; panic!(&quot;Protobuf convert can be derived for structs and enums only.&quot;),     };     data.map(|data| {         data.fields             .iter()             .map(|f| {                 let mut action = Action::Convert;                 for attr in &amp;f.attrs {                     match attr.parse_meta() {                         Ok(syn::Meta::List(ref meta)) if meta.ident == &quot;protobuf_convert&quot; =&gt; {                             for nested in &amp;meta.nested {                                 match nested {                                     syn::NestedMeta::Meta(syn::Meta::Word(ident))                                         if ident == &quot;skip&quot; =&gt;                                     {                                         action = Action::Skip;                                     }                                     _ =&gt; {                                         panic!(&quot;Unknown attribute&quot;);                                     }                                 }                             }                         }                         _ =&gt; {                             \/\/ Other attributes are ignored                         }                     }                 }                 (f.ident.clone().unwrap(), action)             })             .collect()     }) }  fn get_field_names_enum(input: &amp;DeriveInput) -&gt; Option&lt;Vec&lt;Ident&gt;&gt; {     let data = match &amp;input.data {         Data::Struct(..) =&gt; None,         Data::Enum(x) =&gt; Some(x),         _ =&gt; panic!(&quot;Protobuf convert can be derived for structs and enums only.&quot;),     };     data.map(|data| data.variants.iter().map(|f| f.ident.clone()).collect()) }  fn implement_protobuf_convert_from_pb(field_names: &amp;[(Ident, Action)]) -&gt; impl quote::ToTokens {     let mut to_convert = vec![];     let mut to_skip = vec![];     for (x, a) in field_names {         match a {             Action::Convert =&gt; to_convert.push(x),             Action::Skip =&gt; to_skip.push(x),         }     }      let getters = to_convert         .iter()         .map(|i| Ident::new(&amp;format!(&quot;get_{}&quot;, i), Span::call_site()));     let our_struct_names = to_convert.clone();     let our_struct_names_skip = to_skip;      quote! {         fn from_pb(pb: Self::ProtoStruct) -&gt; std::result::Result&lt;Self, _FailureError&gt; {           Ok(Self {            #( #our_struct_names: ProtobufConvert::from_pb(pb.#getters().to_owned())?, )*            #( #our_struct_names_skip: Default::default(), )*           })         }     } }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041c\u044b \u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0435\u0439\u0442 <code>darling<\/code>, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0447\u0435\u043c\u0443 \u043d\u0430\u0448 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0440\u043e\u0447\u0435 \u0438 \u043f\u0440\u043e\u0449\u0435 \u0432 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u0418\u0441\u043a\u043e\u043c\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0432\u044b\u0432\u043e\u0434\u0438\u043c <code>FromUrlQuery<\/code>, \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u043e\u0439, \u043e\u043d\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u043c \u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043e\u043d\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u043b\u0430\u0439\u0444\u0442\u0430\u0439\u043c\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c, \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(FromUrlQuery)] struct OptionalQuery {     first: String,     opt_value: Option&lt;u64&gt;, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 <code>darling<\/code>&#8216;\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u043d\u043e \u043d\u0430\u0441 \u0441\u0435\u0439\u0447\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 \u2014 \u044d\u0442\u043e <a href=\"https:\/\/docs.rs\/darling\/0.10.2\/darling\/trait.FromField.html\" rel=\"nofollow\"><code>FromField<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u043d\u0430\u0441 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u043f\u043e\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438\u0437 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Clone, Debug, FromField)] struct QueryField {     ident: Option&lt;syn::Ident&gt;,     ty: syn::Type, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0425\u043e\u0447\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0437\u043d\u0430\u0442\u044c, \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0435 \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0438\u043b\u0438 \u043d\u0435\u0442, \u0442\u043e \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Clone, Debug, FromField)] struct QueryField {     ident: Option&lt;syn::Ident&gt;,     ty: syn::Type,     vis: syn::Visibility, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0441 \u043c\u0430\u043a\u0440\u043e\u0441 \u2014 \u044d\u0442\u043e <a href=\"https:\/\/docs.rs\/darling\/0.10.2\/darling\/trait.FromDeriveInput.html\" rel=\"nofollow\"><code>FromDeriveInput<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0443\u0436\u0435 \u0434\u043b\u044f \u0446\u0435\u043b\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Debug, FromDeriveInput)] \/\/ \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u044d\u0442\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u043c\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \/\/ \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043c\u0430\u043a\u0440\u043e\u0441 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u0430\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \/\/ \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0445, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443. #[darling(supports(struct_named))] struct FromUrlQuery {     ident: syn::Ident,     \/\/ \u0412 \u0442\u0430\u043a\u043e\u043c \u0432\u043e\u0442 \u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u043b\u0435\u0439 \u0432 \u0443\u0436\u0435     \/\/ \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435.     \/\/ \u0412 darling::ast::Data \u0434\u0432\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u043e \u043f\u043e\u043b\u044f     \/\/ \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u0442\u043e \u043f\u043e\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.     \/\/ \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0441 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c     \/\/ \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c ().     data: darling::ast::Data&lt;(), QueryField&gt;, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0432\u0441\u0435, \u043d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0448 \u043f\u0430\u0440\u0441\u0435\u0440 \u0433\u043e\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">let input: DeriveInput = syn::parse(input).unwrap(); let from_url_query = match FromUrlQuery::from_derive_input(&amp;input) {     Ok(parsed) =&gt; parsed,     Err(e) =&gt; return e.write_errors().into(), };<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u0441\u0432\u0435\u0440\u0445 \u043c\u0435\u0440\u044b, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e URL query \u0432 <code>serde<\/code>. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u0441\u043f\u0440\u044f\u0447\u0435\u043c <code>serde<\/code> \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u043f\u0440\u043e\u0441\u043e\u0447\u0438\u043b\u0441\u044f \u0432 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u043b\u044f \u043d\u0435\u0435 <code>Deserialize<\/code>, \u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0435\u0439\u0442 <a href=\"https:\/\/docs.rs\/serde_urlencoded\/0.6.1\/serde_urlencoded\/\" rel=\"nofollow\"><code>serde_urlencoded<\/code><\/a>. \u041d\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0441\u0430\u043c\u0438\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c <code>serde<\/code> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043c\u044b \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043a\u0440\u0435\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u044d\u043a\u0441\u043f\u043e\u0440\u0442\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[doc(hidden)] pub mod export {     pub use serde;     pub use serde_derive;     pub use serde_urlencoded; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 <code>FromUrlQuery<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl FromUrlQuery {     \/\/ \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0430 \u0438\u043c\u0435\u043d, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441     \/\/ \u043f\u043e\u0441\u0442\u0444\u0438\u043a\u0441\u043e\u043c &quot;Serde&quot;.     fn serde_wrapper_ident(&amp;self) -&gt; syn::Ident {         let ident_str = format!(&quot;{}Serde&quot;, self.ident);         syn::Ident::new(&amp;ident_str, proc_macro2::Span::call_site())     }      \/\/\/ \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u044e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b.     fn impl_serde_wrapper(&amp;self) -&gt; impl ToTokens {         \/\/ \u041c\u044b \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043b\u0438 \u0441\u0435\u0431\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0441 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438         \/\/ \u043f\u043e\u043b\u044f\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 `unwrap` \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0435\u043d.         let fields = self.data.clone().take_struct().unwrap();         \/\/ \u0422\u0443\u0442 \u043c\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043f\u043e\u043b\u0435\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435         \/\/ \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 Query \u0432 SerdeQuery, \u0442\u0430\u043a \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442.         let wrapped_fields = fields.iter().map(|field| {             let ident = &amp;field.ident;             let ty = &amp;field.ty;             quote! { #ident: #ty }         });         let from_fields = fields.iter().map(|field| {             let ident = &amp;field.ident;             quote! { #ident: v.#ident }         });          let wrapped_ident = self.serde_wrapper_ident();         let ident = &amp;self.ident;          \/\/ \u0412 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c `quote!`         \/\/ \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u0432 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u0445, \u0437\u0430         \/\/ \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0442\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f &quot;#&quot; \u0432\u043c\u0435\u0441\u0442\u043e &quot;$&quot;.         quote! {             \/\/ \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c serde \u0438\u0437 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u0440\u0435\u0439\u0442\u0430.             use http_api::export::serde_derive::Deserialize;              #[derive(Deserialize)]             \/\/ \u0410 \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u043c serde \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u044d\u0442\u043e\u0442 \u0440\u0435\u044d\u043a\u0441\u043f\u043e\u0440\u0442, \u0432 \u043d\u0435\u043c \u0435\u0441\u0442\u044c             \/\/ \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442.             #[serde(crate = &quot;http_api::export::serde&quot;)]             struct #wrapped_ident {                 #( #wrapped_fields, )*             }              impl From&lt;#wrapped_ident&gt; for #ident {                 fn from(v: #wrapped_ident) -&gt; Self {                     Self {                         #( #from_fields, )*                     }                 }             }         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430, \u044d\u0442\u043e \u0432\u0441\u0435 \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u043c, \u043f\u043e \u0441\u0443\u0442\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u043c \u0442\u043e, \u0447\u0442\u043e \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044f\u0441\u044c \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043a\u043e\u0433\u043d\u0438\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u043c\u0438, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0432\u0435\u0441\u044c\u043c\u0430 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u043a\u043e\u0434. \u041d\u043e, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0436\u0438\u0437\u043d\u044c \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439; \u0432\u0441\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0433\u043e\u0440\u0430\u0437\u0434\u043e <del>\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435<\/del> \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435 \u0434\u0435\u0440\u0430\u0439\u0432 \u043c\u0430\u043a\u0440\u043e\u0441, \u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043d\u044b\u0439.<\/p>\n<p>  <\/p>\n<h2 id=\"pishem-makros-http_api\">\u041f\u0438\u0448\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441 http_api<\/h2>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <code>FromDeriveInput<\/code>, \u043d\u0435\u0442 \u0432 <code>darling<\/code>&#8216;\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0442\u0440\u0435\u0439\u0442\u043e\u0432, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f \u0441 AST. \u041d\u043e \u043d\u0435 \u0442\u0430\u043a \u0447\u0435\u0440\u0442 \u0441\u0442\u0440\u0430\u0448\u0435\u043d, \u043a\u0430\u043a \u0435\u0433\u043e \u043c\u0430\u043b\u044e\u044e\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c:<\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0434 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[proc_macro_attribute] pub fn http_api(attr: TokenStream, item: TokenStream) -&gt; TokenStream {     \/\/ \u0423 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439     \/\/ \u043d\u0430\u0432\u0435\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441 \u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e AST \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430.     http_api::impl_http_api(attr, item) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043a\u0440\u0430\u0439\u043d\u0435 \u0432\u0430\u0436\u043d\u044b\u0439 \u043d\u044e\u0430\u043d\u0441, \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043d\u0435 \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u043e\u043c\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0432\u0443: \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0435\u0448\u0438\u043c, \u0447\u0442\u043e \u0440\u0430\u0437 \u0443\u0436 \u043d\u0430\u043c \u0434\u0430\u043b\u0438 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0442\u0440\u0435\u0439\u0442\u0430 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u043c\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0441 <code>http_api_endpoint<\/code>), \u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043b\u0438\u0448\u044c \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043f\u0440\u0430\u0432\u044b. \u0414\u0430, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u0438\u0434\u043d\u044b \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 <code>TokenStream<\/code>, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0436\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 &quot;cannot find attribute <code>http_api_endpoint<\/code> in this scope&quot;, \u0447\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0431\u0438\u0432\u0430\u0435\u0442 \u0441 \u0442\u043e\u043b\u043a\u0443. \u041e\u0448\u0438\u0431\u043a\u0430 \u044d\u0442\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a \u0441 \u043d\u0438\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041e \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043d\u0443\u0436\u0434, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u0443\u0441\u0442\u043e\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043d\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 <code>http_api_endpoint<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0440\u0430\u0449\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[proc_macro_attribute] #[doc(hidden)] pub fn http_api_endpoint(_attr: TokenStream, item: TokenStream) -&gt; TokenStream {     \/\/ \u041c\u044b \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u0442\u043e\u043a\u0435\u043d\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e `http_api_endpoint`     \/\/ \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0434\u043b\u044f `http_api` \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430.      \/\/ \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e `http_api_endpoint` \u0434\u043e\u043b\u0436\u0435\u043d \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f     \/\/ \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043d\u044b\u043c \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c, \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e rustc \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442     \/\/ \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0435\u043c\u0443 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432.     item }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0443\u0433\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0438\u043c\u044f.<\/p>\n<p>  <\/p>\n<h2 id=\"razbiraem-metody-interfeysnogo-treyta\">\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0442\u0440\u0435\u0439\u0442\u0430 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/ \u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432: #[http_api_endpoint(method = &quot;#method_type&quot;)] fn #method_name(&amp;self) -&gt; Result&lt;$ResponseType, Error&gt;; \/\/ \u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438: #[http_api_endpoint(method = &quot;#method_type&quot;)] fn #method_name(&amp;self, query: $QueryType) -&gt; Result&lt;$ResponseType, Error&gt;;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u043c \u0442\u0438\u043f\u044b HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0443\u043c\u0435\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Debug)] enum SupportedHttpMethod {     Get,     Post, }  impl FromMeta for SupportedHttpMethod {     fn from_string(value: &amp;str) -&gt; Result&lt;Self, darling::Error&gt; {         match value {             &quot;get&quot; =&gt; Ok(SupportedHttpMethod::Get),             &quot;post&quot; =&gt; Ok(SupportedHttpMethod::Post),             other =&gt; Err(darling::Error::unknown_value(other)),         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043d\u0430\u0431\u043e\u0440 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">#[derive(Debug, FromMeta)] struct EndpointAttrs {     \/\/ \u0414\u0430\u043d\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043c\u044b \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c     \/\/ \u0442\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.     method: SupportedHttpMethod,     \/\/ \u042d\u0442\u043e\u0442 \u0436\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c     \/\/ \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 None, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0443\u043a\u0430\u0436\u0435\u0442 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0432\u043d\u043e:     \/\/ #[http_api_endpoint(method = &quot;get&quot;, rename = &quot;foo&quot;)]     #[darling(default)]     rename: Option&lt;String&gt;, }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0430\u0440\u0441\u0438\u0442\u044c \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <a href=\"https:\/\/docs.rs\/syn\/1.0.14\/syn\/struct.Signature.html\" rel=\"nofollow\"><code>syn::Signature<\/code><\/a>, \u0438 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c darling&#8217;\u0430 \u043c\u044b \u0443\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c: \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0437\u0431\u043e\u0440\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0430\u043c\u0438\u043c, \u043d\u043e \u0432\u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043b\u0435\u0433\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u043d\u0430\u043a\u043e\u043c\u043e\u0433\u043e \u043d\u0430\u043c \u0443\u0436\u0435 <code>FromMeta<\/code>.<br \/>  \u0410 \u0447\u0442\u043e\u0431\u044b \u0441\u0440\u0435\u0434\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0442\u044b\u0441\u043a\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c <code>http_api_endpoint<\/code> \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0432 <a href=\"https:\/\/docs.rs\/syn\/1.0.14\/syn\/enum.NestedMeta.html\" rel=\"nofollow\"><code>syn::NestedMeta<\/code><\/a> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0438\u0434\u0430 <code>(foo = &quot;bar&quot;, boo(first, second))<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">fn find_meta_attrs(name: &amp;str, args: &amp;[syn::Attribute]) -&gt; Option&lt;syn::NestedMeta&gt; {     args.as_ref()         .iter()         .filter_map(|a| a.parse_meta().ok())         .find(|m| m.path().is_ident(name))         .map(syn::NestedMeta::from) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b. \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u0432\u044b\u0448\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c<br \/>  \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u2014 \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u0438 \u0431\u0435\u0437 \u043e\u043d\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/\/ \u0412\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a. fn invalid_method(span: &amp;impl syn::spanned::Spanned) -&gt; darling::Error {     darling::Error::custom(         &quot;API method should have one of `fn foo(&amp;self) -&gt; Result&lt;Bar, Error&gt;` or \\          `fn foo(&amp;self, arg: Foo) -&gt; Result&lt;Bar, Error&gt;` form&quot;,     )     .with_span(span) }  impl ParsedEndpoint {     fn parse(sig: &amp;syn::Signature, attrs: &amp;[syn::Attribute]) -&gt; Result&lt;Self, darling::Error&gt; {         \/\/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0441 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435\u043c \u0430\u0433\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430.         let mut args = sig.inputs.iter();          \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 - \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 &amp;self \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d,         \/\/ \u043d\u0438\u043a\u0430\u043a\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432 &amp;mut self, \u0438\u043b\u0438 \u0441 &amp;self: Arc&lt;Self&gt; \u043c\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c         \/\/ \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.         if let Some(arg) = args.next() {             match arg {                 \/\/ `self` \u0432 `syn` \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a Receiver.                 syn::FnArg::Receiver(syn::Receiver {                     \/\/ \u041d\u0430\u043b\u0438\u0447\u0438\u0435 `reference` \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043d\u0430\u043c, \u0447\u0442\u043e \u0442\u0438\u043f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435                     \/\/ `&amp;self`.                     reference: Some(_),                     \/\/ \u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 `mutability` \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0442\u0438\u043f\u0435                     \/\/ \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u0445 `mut`.                     mutability: None,                     \/\/ \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u043d\u0430\u043c \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b.                     ..                 }) =&gt; {                     \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u0430, \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.                 }                 _ =&gt; {                     \/\/ \u0421 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u043e\u0439 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u043f\u0440\u0435\u043a\u0440\u0430\u0449\u0430\u0435\u043c \u0440\u0430\u0437\u0431\u043e\u0440                     \/\/ \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043e\u0448\u0438\u0431\u043a\u0443.                     return Err(invalid_method(&amp;arg));                 }             }         } else {             return Err(invalid_method(&amp;sig));         }          \/\/ \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0438\u043f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430.         let arg = args             .next()             .map(|arg| match arg {                 \/\/ `FnArg` \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u043b\u0438 `Typed`, \u0438\u043b\u0438 `Receiver`, \u043d\u043e `Receiver`                 \/\/ \u043c\u044b \u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b\u0438 \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e                 \/\/ \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0442\u0438\u043f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.                 syn::FnArg::Typed(arg) =&gt; Ok(arg.ty.clone()),                 \/\/ \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c `self`.                 _ =&gt; unreachable!(&quot;Only first argument can be receiver.&quot;),             })             \/\/ Transpose \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442             \/\/ `Option&lt;Result&lt;...&gt;&gt;` \u0432 `Result&lt;Option&lt;...&gt;&gt;`, \u0447\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442             \/\/ \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430.             .transpose()?;          \/\/ \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043e\u043d \u0442\u043e\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c `Typed`,         \/\/ \u0430 \u043d\u0435 `Receiver`.         let ret = match &amp;sig.output {             syn::ReturnType::Type(_, ty) =&gt; Ok(ty.clone()),             _ =&gt; Err(invalid_method(&amp;sig)),         }?;          \/\/ \u0424\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435, \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0435\u0441\u044f         \/\/ \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043c\u0430\u043a\u0440\u043e\u0441\u0443.         \/\/ \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e `FromMeta::from_nested_meta` \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435.         let attrs = find_meta_attrs(&quot;http_api_endpoint&quot;, attrs)             .map(|meta| EndpointAttrs::from_nested_meta(&amp;&amp;meta))             .unwrap_or_else(|| Err(darling::Error::custom(&quot;todo&quot;)))?;          \/\/\/ \u0412\u0441\u0435, \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u0430 \u0433\u043e\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0437\u0440\u0430\u0449\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.         Ok(Self {             ident: sig.ident.clone(),             arg,             ret,             attrs,         })     } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"razbiraem-interfeysnyy-treyt-celikom\">\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0439 \u0442\u0440\u0435\u0439\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c<\/h2>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0440\u0430\u0437\u0431\u043e\u0440\u0443 \u0442\u0440\u0435\u0439\u0442\u0430 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0432 \u0446\u0435\u043b\u043e\u043c. \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0439 \u0442\u0440\u0435\u0439\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0440\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432.<br \/>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0435\u0433\u043e \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\"> \/\/\/ \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0440\u0435\u0439\u0442, \u043d\u0430\u0431\u043e\u0440 \u0435\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \/\/\/ \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. #[derive(Debug)] struct ParsedApiDefinition {     \/\/\/ \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0442\u0440\u0435\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u043c. \u041c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0435\u0433\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u0432     \/\/\/ \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.     item_trait: syn::ItemTrait,     \/\/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.     endpoints: Vec&lt;ParsedEndpoint&gt;,     \/\/\/ \u0410\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u0439\u0442\u0430.     attrs: ApiAttrs, }  #[derive(Debug, FromMeta)] struct ApiAttrs {     \/\/\/ \u0414\u0430\u043d\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c     \/\/\/ \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u043a warp'\u0443.     warp: syn::Ident, }  impl ParsedApiDefinition {     fn parse(         item_trait: syn::ItemTrait,         attrs: &amp;[syn::NestedMeta],     ) -&gt; Result&lt;Self, darling::Error&gt; {         \/\/ \u0421 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u043e\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0441\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e, \u0441\u0440\u0435\u0434\u0438 \u0438\u0442\u0435\u043c\u043e\u0432 \u0442\u0440\u0435\u0439\u0442\u0430 \u043c\u044b         \/\/ \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u044b, \u0430 \u0437\u0430\u0442\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439         \/\/ \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435.         let endpoints = item_trait             .items             .iter()             .filter_map(|item| {                 if let syn::TraitItem::Method(method) = item {                     Some(method)                 } else {                     None                 }             })             .map(|method| ParsedEndpoint::parse(&amp;method.sig, method.attrs.as_ref()))             .collect::&lt;Result&lt;Vec&lt;_&gt;, darling::Error&gt;&gt;()?;          \/\/ \u041f\u0430\u0440\u0441\u0438\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0442\u0440\u0435\u0439\u0442\u0430.         let attrs = ApiAttrs::from_list(attrs)?;          \/\/ \u0418 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 HTTP API.         Ok(Self {             item_trait,             endpoints,             attrs,         })     } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"perehodim-k-kodogeneracii\">\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0431\u044b\u043b\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0435\u0439\u0442 <a href=\"https:\/\/docs.rs\/warp\/0.2.1\/warp\/\" rel=\"nofollow\"><code>warp<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d <code>warp<\/code> \u0438 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043a \u043d\u0435\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412\u0441\u0435 \u0432 warp&#8217;\u0435 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>Filter<\/code>. \u0424\u0438\u043b\u044c\u0442\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u0432 <code>and<\/code>, <code>map<\/code>, <code>and_then<\/code>, \u0433\u0434\u0435 \u043a\u0430\u0436\u0434\u044b\u0439 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0442\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 GET \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 JSON, \u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0435\u043c \u0447\u0442\u043e-\u0442\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u0442\u0438\u043b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">\/\/\/ \u041c\u044b \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0434\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \/\/\/ \u0432 \u0444\u0438\u043b\u044c\u0442\u0440 warp'\u0430 pub fn simple_get&lt;F, R, E&gt;(name: &amp;'static str, handler: F) -&gt; JsonReply where     F: Fn() -&gt; Result&lt;R, E&gt; + Clone + Send + Sync + 'static,     R: ser::Serialize,     E: Reject, {     \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e GET \u0437\u0430\u043f\u0440\u043e\u0441\u044b,     \/\/ \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442.     warp::get()         \/\/ \u041d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b         \/\/ \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441 \u043f\u0443\u0442\u0435\u043c {name}         .and(warp::path(name))         \/\/ \u0410 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u0435 and_then \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438         \/\/ \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u043e\u0437\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u0432\u0438\u0434\u0435 JSON \u043e\u0431\u044a\u0435\u043a\u0442\u0430         .and_then(move || {             let handler = handler.clone();             \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443             \/\/ \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430\u0448 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0432 async \u0431\u043b\u043e\u043a.             async move {                 match handler() {                     Ok(value) =&gt; Ok(warp::reply::json(&amp;value)),                     \/\/ \u0412 warp'\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a,                     \/\/ \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043a\u0430\u0441\u0430\u0442\u044c\u0441\u044f                     \/\/ \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e                     \/\/ \u0442\u0438\u043f \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430\u0432\u0435\u0440\u0445.                     Err(e) =&gt; Err(warp::reject::custom(e)),                 }             }         })         .boxed() }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u044f \u0441 GET \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043c\u044b \u043b\u0438\u0448\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043e\u0431\u0435\u0440\u0442\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u044b\u0448\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0444\u0438\u043b\u044c\u0442\u0440 \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">pub fn query_get&lt;F, Q, R, E&gt;(name: &amp;'static str, handler: F) -&gt; JsonReply where     F: Fn(Q) -&gt; Result&lt;R, E&gt; + Clone + Send + Sync + 'static,     Q: FromUrlQuery,     R: ser::Serialize,     E: Reject, {     warp::get()         .and(warp::path(name))         \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e \u043f\u043e URL query, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0435\u0442 \u043d\u0430\u043c         \/\/ \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0441 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c query.         .and(warp::filters::query::raw())         .and_then(move |raw_query: String| {             let handler = handler.clone();             async move {                 \/\/ \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0440\u0430\u043d\u0435\u0435 \u0442\u0440\u0435\u0439\u0442                 \/\/ FromUrlQuery \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443                 \/\/ \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0442\u0438\u043f\u043e\u043c.                 let query = Q::from_query_str(&amp;raw_query)                     .map_err(|_| warp::reject::custom(IncorrectQuery))?;                  match handler(query) {                     Ok(value) =&gt; Ok(warp::reply::json(&amp;value)),                     Err(e) =&gt; Err(warp::reject::custom(e)),                 }             }         })         .boxed() }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0432\u0443\u0445 \u0442\u0438\u043f\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0441\u0445\u043e\u0436\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<p>  <\/p>\n<h2 id=\"sobiraem-obrabotchiki-voedino\">\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432\u043e\u0435\u0434\u0438\u043d\u043e<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u0432 <code>and<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0435\u0449\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440<br \/>  <code>or<\/code>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0438\u0437 \u0434\u0432\u0443\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u043f\u043e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0442\u0430\u043a\u0438\u043c<br \/>  \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043f\u0440\u0438\u0447\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438.<br \/>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">use std::net::SocketAddr; use warp::Filter;  \/\/ \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 warp \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432\u0438\u0434\u0430 `\/:u32` \u0438\u043b\u0438 \/\/ `\/:socketaddr` warp::path::param::&lt;u32&gt;()     .or(warp::path::param::&lt;SocketAddr&gt;());<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0442\u0435\u043b\u0430 \u0438\u0441\u043a\u043e\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>serve_ping_interface<\/code>. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 warp \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u0440\u0435\u0439\u0442\u0430, \u0433\u0434\u0435 service \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl ParsedEndpoint {     fn impl_endpoint_handler(&amp;self) -&gt; impl ToTokens {         \/\/ \u0418\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0443\u0442\u0438.         let path = self.endpoint_path();         let ident = &amp;self.ident;          \/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u0435\u0440\u0442\u043e\u043a, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435         \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 warp \u0444\u0438\u043b\u044c\u0442\u0440\u044b.         match (&amp;self.attrs.method, &amp;self.arg) {             (SupportedHttpMethod::Get, None) =&gt; {                 quote! {                     let #ident = http_api::warp_backend::simple_get(#path, {                         let out = service.clone();                         move || out.#ident()                     });                 }             }              (SupportedHttpMethod::Get, Some(_arg)) =&gt; {                 quote! {                     let #ident = http_api::warp_backend::query_get(#path, {                         let out = service.clone();                         move |query| out.#ident(query)                     });                 }             }              (SupportedHttpMethod::Post, None) =&gt; {                 quote! {                     let #ident = http_api::warp_backend::simple_post(#path, {                         let out = service.clone();                         move || out.#ident()                     });                 }             }              (SupportedHttpMethod::Post, Some(_arg)) =&gt; {                 quote! {                     let #ident = http_api::warp_backend::params_post(#path, {                         let out = service.clone();                         move |params| out.#ident(params)                     });                 }             }         }     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u0430 <code>or<\/code> \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0432\u043e\u0435\u0434\u0438\u043d\u043e.<\/p>\n<p>  <\/p>\n<pre><code class=\"rust\">impl ToTokens for ParsedApiDefinition {     fn to_tokens(&amp;self, out: &amp;mut proc_macro2::TokenStream) {         let fn_name = &amp;self.attrs.warp;         let interface = &amp;self.item_trait.ident;          \/\/ \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u044b, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435         \/\/ \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0438\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e         \/\/ \u0438\u043c\u0435\u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430\u0436\u0430.         let (filters, idents): (Vec&lt;_&gt;, Vec&lt;_&gt;) = self             .endpoints             .iter()             .map(|endpoint| {                 let ident = &amp;endpoint.ident;                 let handler = endpoint.impl_endpoint_handler();                  (handler, ident)             })             .unzip();          let mut tail = idents.into_iter();         \/\/ \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0432\u0438\u0434\u0430         \/\/ `a.or(b).or(c).or(d)`, \u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0432\u043d\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442         \/\/ \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0435\u0433\u043e.         let head = tail.next().unwrap();         let serve_impl = quote! {             #head #( .or(#tail) )*         };          \/\/ \u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043a\u043a\u043e\u0440\u0434: \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u0441\u043a\u043e\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.         let tokens = quote! {             fn #fn_name&lt;T&gt;(                 service: T,                 addr: impl Into&lt;std::net::SocketAddr&gt;,             ) -&gt; impl std::future::Future&lt;Output = ()&gt;             where                 T: #interface + Clone + Send + Sync + 'static,             {                 use warp::Filter;                  \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u0440\u0435\u0439\u0442\u0430.                 #( #filters )*                  \/\/ \u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 API \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c                 \/\/ warp \u0441\u0435\u0440\u0432\u0435\u0440.                 warp::serve(#serve_impl).run(addr.into())             }          };         out.extend(tokens)     } }<\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"zaklyuchenie\">\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e derive \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0430\u043a \u0441\u043b\u043e\u0436\u043d\u044b \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438,<br \/>  \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430\u043c.<br \/>  \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0442\u0440\u0435\u0439\u0442\u043e\u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u0435\u043d, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c<br \/>  \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 RPC, \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 Rust&#8217;\u0435.<br \/>  \u041d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u0430\u0436\u0430-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0434\u043b\u044f HTTP<br \/>  \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0442\u0438\u043f\u0430 <code>reqwest<\/code> \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u043a\u043e\u0440\u043d\u044e.<\/p>\n<p>  <\/p>\n<p>\u041d\u0438\u043a\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u043f\u043e\u0439\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0435\u0449\u0435 \u0438 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Open_API\" rel=\"nofollow\">openapi<\/a> \u0438\u043b\u0438 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Swagger_(software)\" rel=\"nofollow\">swagger<\/a><br \/>  \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0442\u0438\u043f\u0430\u0436\u0435\u0439-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432. \u041d\u043e \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0439\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u0438 \u043f\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 Rust \u043a\u043e\u0434\u0430, \u044d\u0442\u043e \u0434\u0430\u0441\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0440 \u0434\u043b\u044f \u043c\u0430\u043d\u0435\u0432\u0440\u043e\u0432.<br \/>  \u0415\u0441\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 \u0432\u0438\u0434\u0435 build \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438<br \/>  <code>syn<\/code> \u0438 <code>quote<\/code>, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u044b\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u044d\u0442\u043e \u0443\u0436\u0435 \u0432\u0434\u0430\u043b\u044c \u0438\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u044f \ud83d\ude42<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434, \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u044d\u0442\u043e\u0439<br \/>  <a href=\"https:\/\/github.com\/alekseysidorov\/playground\/blob\/master\/http_api_trait\" rel=\"nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/div>\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:\/\/habr.com\/ru\/post\/486740\/\"> https:\/\/habr.com\/ru\/post\/486740\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/486740\/\">\n<p>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0432 Rust \u2014 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u043e\u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0431\u0435\u0437 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u043e\u043d\u043d\u044b \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0438\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043b\u0438, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043a\u0440\u0435\u0439\u0442\u0430 <a href=\"https:\/\/docs.rs\/async-trait\/0.1.22\/async_trait\/\" rel=\"nofollow\"><code>async_trait<\/code><\/a>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u043d\u043e\u0433\u0438\u0435 \u0432\u043f\u043e\u043b\u043d\u0435 \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u043e\u0431\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0440\u0430\u0437\u0431\u043e\u0440 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 &quot;\u0437\u0430\u043a\u0430\u0442 \u0441\u043e\u043b\u043d\u0446\u0430 \u0432\u0440\u0443\u0447\u043d\u0443\u044e&quot;, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0447\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0430\u0442\u044c \u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u043d\u0438\u0437\u043a\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0443\u0434\u0430\u0447\u043d\u044b\u043c\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438 \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e.<\/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-298138","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298138","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=298138"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298138\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}