mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
225 lines
55 KiB
HTML
225 lines
55 KiB
HTML
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A collection of `Route`s that respond to the same path pattern."><title>Resource in actix_web - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="actix_web" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../actix_web/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../actix_web/index.html">actix_web</a><span class="version">4.6.0</span></h2></div><h2 class="location"><a href="#">Resource</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.app_data">app_data</a></li><li><a href="#method.data">data</a></li><li><a href="#method.default_service">default_service</a></li><li><a href="#method.delete">delete</a></li><li><a href="#method.get">get</a></li><li><a href="#method.guard">guard</a></li><li><a href="#method.head">head</a></li><li><a href="#method.name">name</a></li><li><a href="#method.new">new</a></li><li><a href="#method.patch">patch</a></li><li><a href="#method.post">post</a></li><li><a href="#method.put">put</a></li><li><a href="#method.route">route</a></li><li><a href="#method.to">to</a></li><li><a href="#method.trace">trace</a></li><li><a href="#method.wrap">wrap</a></li><li><a href="#method.wrap_fn">wrap_fn</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-HttpServiceFactory-for-Resource%3CT%3E">HttpServiceFactory</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-Resource%3CT%3E">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-Resource%3CT%3E">!Send</a></li><li><a href="#impl-Sync-for-Resource%3CT%3E">!Sync</a></li><li><a href="#impl-UnwindSafe-for-Resource%3CT%3E">!UnwindSafe</a></li><li><a href="#impl-Freeze-for-Resource%3CT%3E">Freeze</a></li><li><a href="#impl-Unpin-for-Resource%3CT%3E">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut<T></a></li><li><
|
|||
|
<p>Resource in turn has at least one route. Route consists of an handlers objects and list of
|
|||
|
guards (objects that implement <code>Guard</code> trait). Resources and routes uses builder-like pattern
|
|||
|
for configuration. During request handling, resource object iterate through all routes and check
|
|||
|
guards for specific route, if request matches all guards, route considered matched and route
|
|||
|
handler get called.</p>
|
|||
|
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{web, App, HttpResponse};
|
|||
|
|
|||
|
<span class="kw">let </span>app = App::new().service(
|
|||
|
web::resource(<span class="string">"/"</span>)
|
|||
|
.get(|| HttpResponse::Ok())
|
|||
|
.post(|| <span class="kw">async </span>{ <span class="string">"Hello World!" </span>})
|
|||
|
);</code></pre></div>
|
|||
|
<p>If no matching route is found, an empty 405 response is returned which includes an
|
|||
|
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.6">appropriate Allow header</a>. This default behavior can be overridden using
|
|||
|
<a href="struct.Resource.html#method.default_service" title="method actix_web::Resource::default_service"><code>default_service()</code></a>.</p>
|
|||
|
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Resource" class="impl"><a class="src rightside" href="../src/actix_web/resource.rs.html#62-92">source</a><a href="#impl-Resource" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#64-91">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a><T: <a class="trait" href="../actix_router/pattern/trait.IntoPatterns.html" title="trait actix_router::pattern::IntoPatterns">IntoPatterns</a>>(path: T) -> <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a></h4></section></summary><div class="docblock"><p>Constructs new resource that matches a <code>path</code> pattern.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Resource%3CT%3E" class="impl"><a class="src rightside" href="../src/actix_web/resource.rs.html#94-368">source</a><a href="#impl-Resource%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T><div class="where">where
|
|||
|
T: <a class="trait" href="dev/trait.ServiceFactory.html" title="trait actix_web::dev::ServiceFactory">ServiceFactory</a><<a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>, Config = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error = <a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>, InitError = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.name" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#101-104">source</a><h4 class="code-header">pub fn <a href="#method.name" class="fn">name</a>(self, name: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> Self</h4></section></summary><div class="docblock"><p>Set resource name.</p>
|
|||
|
<p>Name is used for url generation.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.guard" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#127-130">source</a><h4 class="code-header">pub fn <a href="#method.guard" class="fn">guard</a><G: <a class="trait" href="guard/trait.Guard.html" title="trait actix_web::guard::Guard">Guard</a> + 'static>(self, guard: G) -> Self</h4></section></summary><div class="docblock"><p>Add match guard to a resource.</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{web, guard, App, HttpResponse};
|
|||
|
|
|||
|
<span class="kw">async fn </span>index(data: web::Path<(String, String)>) -> <span class="kw-2">&</span><span class="lifetime">'static </span>str {
|
|||
|
<span class="string">"Welcome!"
|
|||
|
</span>}
|
|||
|
|
|||
|
<span class="kw">let </span>app = App::new()
|
|||
|
.service(
|
|||
|
web::resource(<span class="string">"/app"</span>)
|
|||
|
.guard(guard::Header(<span class="string">"content-type"</span>, <span class="string">"text/plain"</span>))
|
|||
|
.route(web::get().to(index))
|
|||
|
)
|
|||
|
.service(
|
|||
|
web::resource(<span class="string">"/app"</span>)
|
|||
|
.guard(guard::Header(<span class="string">"content-type"</span>, <span class="string">"text/json"</span>))
|
|||
|
.route(web::get().to(|| HttpResponse::MethodNotAllowed()))
|
|||
|
);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.route" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#168-171">source</a><h4 class="code-header">pub fn <a href="#method.route" class="fn">route</a>(self, route: <a class="struct" href="struct.Route.html" title="struct actix_web::Route">Route</a>) -> Self</h4></section></summary><div class="docblock"><p>Register a new route.</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{web, guard, App, HttpResponse};
|
|||
|
|
|||
|
<span class="kw">let </span>app = App::new().service(
|
|||
|
web::resource(<span class="string">"/"</span>).route(
|
|||
|
web::route()
|
|||
|
.guard(guard::Any(guard::Get()).or(guard::Put()))
|
|||
|
.guard(guard::Header(<span class="string">"Content-Type"</span>, <span class="string">"text/plain"</span>))
|
|||
|
.to(|| HttpResponse::Ok()))
|
|||
|
);</code></pre></div>
|
|||
|
<p>Multiple routes could be added to a resource. Resource object uses
|
|||
|
match guards for route selection.</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{web, guard, App};
|
|||
|
|
|||
|
<span class="kw">let </span>app = App::new().service(
|
|||
|
web::resource(<span class="string">"/container/"</span>)
|
|||
|
.route(web::get().to(get_handler))
|
|||
|
.route(web::post().to(post_handler))
|
|||
|
.route(web::delete().to(delete_handler))
|
|||
|
);
|
|||
|
</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.app_data" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#206-212">source</a><h4 class="code-header">pub fn <a href="#method.app_data" class="fn">app_data</a><U: 'static>(self, data: U) -> Self</h4></section></summary><div class="docblock"><p>Add resource data.</p>
|
|||
|
<p>Data of different types from parent contexts will still be accessible. Any <code>Data<T></code> types
|
|||
|
set here can be extracted in handlers using the <code>Data<T></code> extractor.</p>
|
|||
|
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::cell::Cell;
|
|||
|
<span class="kw">use </span>actix_web::{web, App, HttpRequest, HttpResponse, Responder};
|
|||
|
|
|||
|
<span class="kw">struct </span>MyData {
|
|||
|
count: std::cell::Cell<usize>,
|
|||
|
}
|
|||
|
|
|||
|
<span class="kw">async fn </span>handler(req: HttpRequest, counter: web::Data<MyData>) -> <span class="kw">impl </span>Responder {
|
|||
|
<span class="comment">// note this cannot use the Data<T> extractor because it was not added with it
|
|||
|
</span><span class="kw">let </span>incr = <span class="kw-2">*</span>req.app_data::<usize>().unwrap();
|
|||
|
<span class="macro">assert_eq!</span>(incr, <span class="number">3</span>);
|
|||
|
|
|||
|
<span class="comment">// update counter using other value from app data
|
|||
|
</span>counter.count.set(counter.count.get() + incr);
|
|||
|
|
|||
|
HttpResponse::Ok().body(counter.count.get().to_string())
|
|||
|
}
|
|||
|
|
|||
|
<span class="kw">let </span>app = App::new().service(
|
|||
|
web::resource(<span class="string">"/"</span>)
|
|||
|
.app_data(<span class="number">3usize</span>)
|
|||
|
.app_data(web::Data::new(MyData { count: Default::default() }))
|
|||
|
.route(web::get().to(handler))
|
|||
|
);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.data" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#218-220">source</a><h4 class="code-header">pub fn <a href="#method.data" class="fn">data</a><U: 'static>(self, data: U) -> Self</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 4.0.0: Use <code>.app_data(Data::new(val))</code> instead.</span></div></span></summary><div class="docblock"><p>Add resource data after wrapping in <code>Data<T></code>.</p>
|
|||
|
<p>Deprecated in favor of <a href="struct.Resource.html#method.app_data" title="method actix_web::Resource::app_data"><code>app_data</code></a>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.to" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#241-249">source</a><h4 class="code-header">pub fn <a href="#method.to" class="fn">to</a><F, Args>(self, handler: F) -> Self<div class="where">where
|
|||
|
F: <a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a><Args>,
|
|||
|
Args: <a class="trait" href="trait.FromRequest.html" title="trait actix_web::FromRequest">FromRequest</a> + 'static,
|
|||
|
F::<a class="associatedtype" href="trait.Handler.html#associatedtype.Output" title="type actix_web::Handler::Output">Output</a>: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Register a new route and add handler. This route matches all requests.</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{App, HttpRequest, HttpResponse, web};
|
|||
|
|
|||
|
<span class="kw">async fn </span>index(req: HttpRequest) -> HttpResponse {
|
|||
|
<span class="macro">todo!</span>()
|
|||
|
}
|
|||
|
|
|||
|
App::new().service(web::resource(<span class="string">"/"</span>).to(index));</code></pre></div>
|
|||
|
<p>This is shortcut for:</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>App::new().service(web::resource(<span class="string">"/"</span>).route(web::route().to(index)));</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.wrap" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#259-291">source</a><h4 class="code-header">pub fn <a href="#method.wrap" class="fn">wrap</a><M, B>(
|
|||
|
self,
|
|||
|
mw: M
|
|||
|
) -> <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><impl <a class="trait" href="dev/trait.ServiceFactory.html" title="trait actix_web::dev::ServiceFactory">ServiceFactory</a><<a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>, Config = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Response = <a class="struct" href="dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><B>, Error = <a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>, InitError = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>><div class="where">where
|
|||
|
M: <a class="trait" href="dev/trait.Transform.html" title="trait actix_web::dev::Transform">Transform</a><T::<a class="associatedtype" href="dev/trait.ServiceFactory.html#associatedtype.Service" title="type actix_web::dev::ServiceFactory::Service">Service</a>, <a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>, Response = <a class="struct" href="dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><B>, Error = <a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>, InitError = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> + 'static,
|
|||
|
B: <a class="trait" href="body/trait.MessageBody.html" title="trait actix_web::body::MessageBody">MessageBody</a>,</div></h4></section></summary><div class="docblock"><p>Registers a resource middleware.</p>
|
|||
|
<p><code>mw</code> is a middleware component (type), that can modify the request and response across all
|
|||
|
routes managed by this <code>Resource</code>.</p>
|
|||
|
<p>See <a href="struct.App.html#method.wrap" title="method actix_web::App::wrap"><code>App::wrap</code></a> for more details.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.wrap_fn" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#302-329">source</a><h4 class="code-header">pub fn <a href="#method.wrap_fn" class="fn">wrap_fn</a><F, R, B>(
|
|||
|
self,
|
|||
|
mw: F
|
|||
|
) -> <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><impl <a class="trait" href="dev/trait.ServiceFactory.html" title="trait actix_web::dev::ServiceFactory">ServiceFactory</a><<a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>, Config = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Response = <a class="struct" href="dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><B>, Error = <a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>, InitError = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>><div class="where">where
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>, &T::<a class="associatedtype" href="dev/trait.ServiceFactory.html#associatedtype.Service" title="type actix_web::dev::ServiceFactory::Service">Service</a>) -> R + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + 'static,
|
|||
|
R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><B>, <a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>>>,
|
|||
|
B: <a class="trait" href="body/trait.MessageBody.html" title="trait actix_web::body::MessageBody">MessageBody</a>,</div></h4></section></summary><div class="docblock"><p>Registers a resource function middleware.</p>
|
|||
|
<p><code>mw</code> is a closure that runs during inbound and/or outbound processing in the request
|
|||
|
life-cycle (request -> response), modifying request/response as necessary, across all
|
|||
|
requests handled by the <code>Resource</code>.</p>
|
|||
|
<p>See <a href="struct.App.html#method.wrap_fn" title="method actix_web::App::wrap_fn"><code>App::wrap_fn</code></a> for examples and more details.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.default_service" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#353-367">source</a><h4 class="code-header">pub fn <a href="#method.default_service" class="fn">default_service</a><F, U>(self, f: F) -> Self<div class="where">where
|
|||
|
F: IntoServiceFactory<U, <a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>>,
|
|||
|
U: <a class="trait" href="dev/trait.ServiceFactory.html" title="trait actix_web::dev::ServiceFactory">ServiceFactory</a><<a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>, Config = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Response = <a class="struct" href="dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a>, Error = <a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>> + 'static,
|
|||
|
U::<a class="associatedtype" href="dev/trait.ServiceFactory.html#associatedtype.InitError" title="type actix_web::dev::ServiceFactory::InitError">InitError</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>,</div></h4></section></summary><div class="docblock"><p>Sets the default service to be used if no matching route is found.</p>
|
|||
|
<p>Unlike <a href="struct.Scope.html" title="struct actix_web::Scope"><code>Scope</code></a>s, a <code>Resource</code> does <em>not</em> inherit its parent’s default service. You can
|
|||
|
use a <a href="struct.Route.html" title="struct actix_web::Route"><code>Route</code></a> as default service.</p>
|
|||
|
<p>If a custom default service is not registered, an empty <code>405 Method Not Allowed</code> response
|
|||
|
with an appropriate Allow header will be sent instead.</p>
|
|||
|
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{App, HttpResponse, web};
|
|||
|
|
|||
|
<span class="kw">let </span>resource = web::resource(<span class="string">"/test"</span>)
|
|||
|
.route(web::get().to(HttpResponse::Ok))
|
|||
|
.default_service(web::to(|| {
|
|||
|
HttpResponse::BadRequest()
|
|||
|
}));
|
|||
|
|
|||
|
App::new().service(resource);</code></pre></div>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Resource%3CT%3E-1" class="impl"><a class="src rightside" href="../src/actix_web/resource.rs.html#396-407">source</a><a href="#impl-Resource%3CT%3E-1" class="anchor">§</a><h3 class="code-header">impl<T> <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T><div class="where">where
|
|||
|
T: <a class="trait" href="dev/trait.ServiceFactory.html" title="trait actix_web::dev::ServiceFactory">ServiceFactory</a><<a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>, Config = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error = <a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>, InitError = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>,</div></h3></section></summary><div class="docblock"><p>Concise routes for well-known HTTP methods.</p>
|
|||
|
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.get" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#400">source</a><h4 class="code-header">pub fn <a href="#method.get" class="fn">get</a><F, Args>(self, handler: F) -> Self<div class="where">where
|
|||
|
F: <a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a><Args>,
|
|||
|
Args: <a class="trait" href="trait.FromRequest.html" title="trait actix_web::FromRequest">FromRequest</a> + 'static,
|
|||
|
F::<a class="associatedtype" href="trait.Handler.html#associatedtype.Output" title="type actix_web::Handler::Output">Output</a>: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Adds a GET route.</p>
|
|||
|
<p>Use <a href="struct.Resource.html#method.route" title="method actix_web::Resource::route"><code>route</code></a> if you need to add additional guards.</p>
|
|||
|
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>web::resource(<span class="string">"/"</span>)
|
|||
|
.get(|| <span class="kw">async </span>{ <span class="string">"Hello World!" </span>})</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.post" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#401">source</a><h4 class="code-header">pub fn <a href="#method.post" class="fn">post</a><F, Args>(self, handler: F) -> Self<div class="where">where
|
|||
|
F: <a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a><Args>,
|
|||
|
Args: <a class="trait" href="trait.FromRequest.html" title="trait actix_web::FromRequest">FromRequest</a> + 'static,
|
|||
|
F::<a class="associatedtype" href="trait.Handler.html#associatedtype.Output" title="type actix_web::Handler::Output">Output</a>: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Adds a POST route.</p>
|
|||
|
<p>Use <a href="struct.Resource.html#method.route" title="method actix_web::Resource::route"><code>route</code></a> if you need to add additional guards.</p>
|
|||
|
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>web::resource(<span class="string">"/"</span>)
|
|||
|
.post(|| <span class="kw">async </span>{ <span class="string">"Hello World!" </span>})</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.put" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#402">source</a><h4 class="code-header">pub fn <a href="#method.put" class="fn">put</a><F, Args>(self, handler: F) -> Self<div class="where">where
|
|||
|
F: <a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a><Args>,
|
|||
|
Args: <a class="trait" href="trait.FromRequest.html" title="trait actix_web::FromRequest">FromRequest</a> + 'static,
|
|||
|
F::<a class="associatedtype" href="trait.Handler.html#associatedtype.Output" title="type actix_web::Handler::Output">Output</a>: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Adds a PUT route.</p>
|
|||
|
<p>Use <a href="struct.Resource.html#method.route" title="method actix_web::Resource::route"><code>route</code></a> if you need to add additional guards.</p>
|
|||
|
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>web::resource(<span class="string">"/"</span>)
|
|||
|
.put(|| <span class="kw">async </span>{ <span class="string">"Hello World!" </span>})</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.patch" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#403">source</a><h4 class="code-header">pub fn <a href="#method.patch" class="fn">patch</a><F, Args>(self, handler: F) -> Self<div class="where">where
|
|||
|
F: <a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a><Args>,
|
|||
|
Args: <a class="trait" href="trait.FromRequest.html" title="trait actix_web::FromRequest">FromRequest</a> + 'static,
|
|||
|
F::<a class="associatedtype" href="trait.Handler.html#associatedtype.Output" title="type actix_web::Handler::Output">Output</a>: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Adds a PATCH route.</p>
|
|||
|
<p>Use <a href="struct.Resource.html#method.route" title="method actix_web::Resource::route"><code>route</code></a> if you need to add additional guards.</p>
|
|||
|
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>web::resource(<span class="string">"/"</span>)
|
|||
|
.patch(|| <span class="kw">async </span>{ <span class="string">"Hello World!" </span>})</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.delete" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#404">source</a><h4 class="code-header">pub fn <a href="#method.delete" class="fn">delete</a><F, Args>(self, handler: F) -> Self<div class="where">where
|
|||
|
F: <a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a><Args>,
|
|||
|
Args: <a class="trait" href="trait.FromRequest.html" title="trait actix_web::FromRequest">FromRequest</a> + 'static,
|
|||
|
F::<a class="associatedtype" href="trait.Handler.html#associatedtype.Output" title="type actix_web::Handler::Output">Output</a>: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Adds a DELETE route.</p>
|
|||
|
<p>Use <a href="struct.Resource.html#method.route" title="method actix_web::Resource::route"><code>route</code></a> if you need to add additional guards.</p>
|
|||
|
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>web::resource(<span class="string">"/"</span>)
|
|||
|
.delete(|| <span class="kw">async </span>{ <span class="string">"Hello World!" </span>})</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.head" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#405">source</a><h4 class="code-header">pub fn <a href="#method.head" class="fn">head</a><F, Args>(self, handler: F) -> Self<div class="where">where
|
|||
|
F: <a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a><Args>,
|
|||
|
Args: <a class="trait" href="trait.FromRequest.html" title="trait actix_web::FromRequest">FromRequest</a> + 'static,
|
|||
|
F::<a class="associatedtype" href="trait.Handler.html#associatedtype.Output" title="type actix_web::Handler::Output">Output</a>: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Adds a HEAD route.</p>
|
|||
|
<p>Use <a href="struct.Resource.html#method.route" title="method actix_web::Resource::route"><code>route</code></a> if you need to add additional guards.</p>
|
|||
|
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>web::resource(<span class="string">"/"</span>)
|
|||
|
.head(|| <span class="kw">async </span>{ <span class="string">"Hello World!" </span>})</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.trace" class="method"><a class="src rightside" href="../src/actix_web/resource.rs.html#406">source</a><h4 class="code-header">pub fn <a href="#method.trace" class="fn">trace</a><F, Args>(self, handler: F) -> Self<div class="where">where
|
|||
|
F: <a class="trait" href="trait.Handler.html" title="trait actix_web::Handler">Handler</a><Args>,
|
|||
|
Args: <a class="trait" href="trait.FromRequest.html" title="trait actix_web::FromRequest">FromRequest</a> + 'static,
|
|||
|
F::<a class="associatedtype" href="trait.Handler.html#associatedtype.Output" title="type actix_web::Handler::Output">Output</a>: <a class="trait" href="trait.Responder.html" title="trait actix_web::Responder">Responder</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Adds a TRACE route.</p>
|
|||
|
<p>Use <a href="struct.Resource.html#method.route" title="method actix_web::Resource::route"><code>route</code></a> if you need to add additional guards.</p>
|
|||
|
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>web::resource(<span class="string">"/"</span>)
|
|||
|
.trace(|| <span class="kw">async </span>{ <span class="string">"Hello World!" </span>})</code></pre></div>
|
|||
|
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-HttpServiceFactory-for-Resource%3CT%3E" class="impl"><a class="src rightside" href="../src/actix_web/resource.rs.html#409-457">source</a><a href="#impl-HttpServiceFactory-for-Resource%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T, B> <a class="trait" href="dev/trait.HttpServiceFactory.html" title="trait actix_web::dev::HttpServiceFactory">HttpServiceFactory</a> for <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T><div class="where">where
|
|||
|
T: <a class="trait" href="dev/trait.ServiceFactory.html" title="trait actix_web::dev::ServiceFactory">ServiceFactory</a><<a class="struct" href="dev/struct.ServiceRequest.html" title="struct actix_web::dev::ServiceRequest">ServiceRequest</a>, Config = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Response = <a class="struct" href="dev/struct.ServiceResponse.html" title="struct actix_web::dev::ServiceResponse">ServiceResponse</a><B>, Error = <a class="struct" href="error/struct.Error.html" title="struct actix_web::error::Error">Error</a>, InitError = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> + 'static,
|
|||
|
B: <a class="trait" href="body/trait.MessageBody.html" title="trait actix_web::body::MessageBody">MessageBody</a> + 'static,</div></h3></section></summary><div class="impl-items"><section id="method.register" class="method trait-impl"><a class="src rightside" href="../src/actix_web/resource.rs.html#420-456">source</a><a href="#method.register" class="anchor">§</a><h4 class="code-header">fn <a href="dev/trait.HttpServiceFactory.html#tymethod.register" class="fn">register</a>(self, config: &mut <a class="struct" href="dev/struct.AppService.html" title="struct actix_web::dev::AppService">AppService</a>)</h4></section></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Resource%3CT%3E" class="impl"><a href="#impl-Freeze-for-Resource%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T><div class="where">where
|
|||
|
T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a>,</div></h3></section><section id="impl-RefUnwindSafe-for-Resource%3CT%3E" class="impl"><a href="#impl-RefUnwindSafe-for-Resource%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T = ResourceEndpoint> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T></h3></section><section id="impl-Send-for-Resource%3CT%3E" class="impl"><a href="#impl-Send-for-Resource%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T = ResourceEndpoint> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T></h3></section><section id="impl-Sync-for-Resource%3CT%3E" class="impl"><a href="#impl-Sync-for-Resource%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T = ResourceEndpoint> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T></h3></section><section id="impl-Unpin-for-Resource%3CT%3E" class="impl"><a href="#impl-Unpin-for-Resource%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T><div class="where">where
|
|||
|
T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-Resource%3CT%3E" class="impl"><a href="#impl-UnwindSafe-for-Resource%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T = ResourceEndpoint> !<a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Resource.html" title="struct actix_web::Resource">Resource</a><T></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
|||
|
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
|||
|
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
|||
|
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#765">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#768">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Instrument-for-T" class="impl"><a href="#impl-Instrument-for-T" class="anchor">§</a><h3 class="code-header">impl<T> Instrument for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.instrument" class="method trait-impl"><a href="#method.instrument" class="anchor">§</a><h4 class="code-header">fn <a class="fn">instrument</a>(self, span: Span) -> Instrumented<Self></h4></section></summary><div class='docblock'>Instruments this type with the provided [<code>Span</code>], returning an
|
|||
|
<code>Instrumented</code> wrapper. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.in_current_span" class="method trait-impl"><a href="#method.in_current_span" class="anchor">§</a><h4 class="code-header">fn <a class="fn">in_current_span</a>(self) -> Instrumented<Self></h4></section></summary><div class='docblock'>Instruments this type with the <a href="super::Span::current()">current</a> <a href="crate::Span"><code>Span</code></a>, returning an
|
|||
|
<code>Instrumented</code> wrapper. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#748-750">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#758">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
|||
|
<p>That is, this conversion is whatever the implementation of
|
|||
|
<code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Same-for-T" class="impl"><a class="src rightside" href="https://docs.rs/typenum/1.17.0/src/typenum/type_operators.rs.html#34">source</a><a href="#impl-Same-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html" title="trait typenum::type_operators::Same">Same</a> for T</h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl"><a href="#associatedtype.Output" class="anchor">§</a><h4 class="code-header">type <a href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html#associatedtype.Output" class="associatedtype">Output</a> = T</h4></section></summary><div class='docblock'>Should always be <code>Self</code></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#805-807">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#812">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#790-792">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#797">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-VZip%3CV%3E-for-T" class="impl"><a href="#impl-VZip%3CV%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<V, T> VZip<V> for T<div class="where">where
|
|||
|
V: MultiLane<T>,</div></h3></section></summary><div class="impl-items"><section id="method.vzip" class="method trait-impl"><a href="#method.vzip" class="anchor">§</a><h4 class="code-header">fn <a class="fn">vzip</a>(self) -> V</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-WithSubscriber-for-T" class="impl"><a href="#impl-WithSubscriber-for-T" class="anchor">§</a><h3 class="code-header">impl<T> WithSubscriber for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.with_subscriber" class="method trait-impl"><a href="#method.with_subscriber" class="anchor">§</a><h4 class="code-header">fn <a class="fn">with_subscriber</a><S>(self, subscriber: S) -> WithDispatch<Self><div class="where">where
|
|||
|
S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><Dispatch>,</div></h4></section></summary><div class='docblock'>Attaches the provided <a href="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
|
|||
|
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.with_current_subscriber" class="method trait-impl"><a href="#method.with_current_subscriber" class="anchor">§</a><h4 class="code-header">fn <a class="fn">with_current_subscriber</a>(self) -> WithDispatch<Self></h4></section></summary><div class='docblock'>Attaches the current <a href="crate::dispatcher#setting-the-default-subscriber">default</a> <a href="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
|
|||
|
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details></div></details></div></section></div></main></body></html>
|