[−][src]Struct spirit_reqwest::futures::AtomicClient
A storage for one Client
that can be atomically exchanged under the hood.
This acts as a proxy for a Client
. This is cheap to clone all cloned handles refer to
the same client. It has most of the Client
's methods directly on itself, the others can
be accessed through the client
method.
It also supports the replace
method, by which it is possible to exchange the client
inside.
While it can be used separately, it is best paired with a
ReqwestClient
configuration fragment inside Spirit
to have an
up to date client around.
Warning
As it is possible for the client to get replaced at any time by another thread, therefore
successive calls to eg. get
may happen on different clients. If this is a problem, a
caller may get a specific client by the client
method ‒ the client returned will not
change for as long as it is held (if the one inside here is replaced, both are kept alive
until the return value of client
goes out of scope).
Panics
Trying to access the client if the AtomicClient
was created with empty
and wasn't
set yet (either by Spirit
or by explicit replace
) will result into panic.
If you may use the client sooner, prefer either default
or unconfigured
.
Implementations
impl AtomicClient
[src]
pub fn empty() -> Self
[src]
Creates an empty AtomicClient
.
This is effectively a NULL
. It'll panic until a value is set, either by replace
or by Spirit
behind the scenes. It is appropriate if the caller is sure it will get
configured before being accessed and creating an intermediate client first would be a
waste.
pub fn unconfigured() -> Self
[src]
Creates an AtomicClient
with default Client
inside.
pub fn replace<C: Into<Arc<Client>>>(&self, by: C)
[src]
Replaces the content of this AtomicClient
with a new Client
.
If you want to create a new AtomicClient
out of a client, use From
. This is
meant for replacing the content of already existing ones.
This replaces it for all connected handles (eg. created by cloning from the same
original AtomicClient
).
pub fn client(&self) -> Arc<Client>
[src]
Returns a handle to the Client
currently held inside.
This serves a dual purpose:
- If some functionality is not directly provided by the
AtomicClient
proxy. - If the caller needs to ensure a series of requests is performed using the same client.
While the content of the
AtomicClient
can change between calls to it, the content of theArc
can't. While it is possible the client insideAtomicClient
exchanged, theArc
keeps itsClient
around (which may lead to multipleClient
s in memory).
pub fn request<U: IntoUrl>(&self, method: Method, url: U) -> RequestBuilder
[src]
Starts building an arbitrary request using the current client.
This is forwarded to Client::request
.
pub fn get<U: IntoUrl>(&self, url: U) -> RequestBuilder
[src]
Starts building a GET request.
This is forwarded to Client::get
.
pub fn post<U: IntoUrl>(&self, url: U) -> RequestBuilder
[src]
Starts building a POST request.
This is forwarded to Client::post
.
pub fn put<U: IntoUrl>(&self, url: U) -> RequestBuilder
[src]
Starts building a PUT request.
This is forwarded to Client::put
.
pub fn patch<U: IntoUrl>(&self, url: U) -> RequestBuilder
[src]
Starts building a PATCH request.
This is forwarded to Client::patch
.
pub fn delete<U: IntoUrl>(&self, url: U) -> RequestBuilder
[src]
Starts building a DELETE request.
This is forwarded to Client::delete
.
pub fn head<U: IntoUrl>(&self, url: U) -> RequestBuilder
[src]
Starts building a HEAD request.
This is forwarded to Client::head
.
Trait Implementations
impl Clone for AtomicClient
[src]
fn clone(&self) -> AtomicClient
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for AtomicClient
[src]
impl Default for AtomicClient
[src]
impl<C: Into<Arc<Client>>> From<C> for AtomicClient
[src]
impl<O, C> Installer<Client, O, C> for AtomicClient
[src]
type UninstallHandle = ()
A handle representing lifetime of the resource. Read more
fn install(&mut self, client: Client, name: &'static str)
[src]
fn init<B>(
&mut self,
builder: B,
_name: &'static str
) -> Result<B, Box<dyn Error + 'static + Sync + Send>> where
B: Extensible<Opts = O, Config = C, Ok = B>,
<B as Extensible>::Config: DeserializeOwned,
<B as Extensible>::Config: Send,
<B as Extensible>::Config: Sync,
<B as Extensible>::Config: 'static,
<B as Extensible>::Opts: StructOpt,
<B as Extensible>::Opts: Send,
<B as Extensible>::Opts: Sync,
<B as Extensible>::Opts: 'static,
[src]
&mut self,
builder: B,
_name: &'static str
) -> Result<B, Box<dyn Error + 'static + Sync + Send>> where
B: Extensible<Opts = O, Config = C, Ok = B>,
<B as Extensible>::Config: DeserializeOwned,
<B as Extensible>::Config: Send,
<B as Extensible>::Config: Sync,
<B as Extensible>::Config: 'static,
<B as Extensible>::Opts: StructOpt,
<B as Extensible>::Opts: Send,
<B as Extensible>::Opts: Sync,
<B as Extensible>::Opts: 'static,
Auto Trait Implementations
impl !RefUnwindSafe for AtomicClient
impl Send for AtomicClient
impl Sync for AtomicClient
impl Unpin for AtomicClient
impl !UnwindSafe for AtomicClient
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoResult<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,