pub struct TimewebClient { /* private fields */ }Expand description
High-level entry point: an authenticated configuration plus retries.
The generated operations stay free functions over a
Configuration; this wrapper owns that configuration and re-runs an
operation closure according to its RetryPolicy:
use timeweb_rs::{TimewebClient, apis::servers_api};
let client = TimewebClient::new("your-jwt-token");
let servers = client
.execute(|| servers_api::get_servers(client.config(), None, None))
.await?;Implementations§
Source§impl TimewebClient
impl TimewebClient
Sourcepub fn new(token: impl Into<String>) -> Self
pub fn new(token: impl Into<String>) -> Self
Client for the production API, authenticated with a JWT token.
Sourcepub fn with_base_url(
token: impl Into<String>,
base_url: impl Into<String>,
) -> Self
pub fn with_base_url( token: impl Into<String>, base_url: impl Into<String>, ) -> Self
Client for a custom base URL (mock server, proxy).
Sourcepub const fn with_policy(self, policy: RetryPolicy) -> Self
pub const fn with_policy(self, policy: RetryPolicy) -> Self
Replaces the retry policy.
Sourcepub const fn config(&self) -> &Configuration
pub const fn config(&self) -> &Configuration
The configuration to pass to the generated operations.
Sourcepub async fn execute<T, E, F, Fut>(&self, operation: F) -> Result<T, Error<E>>
pub async fn execute<T, E, F, Fut>(&self, operation: F) -> Result<T, Error<E>>
Runs an operation, retrying it under the client’s RetryPolicy.
The closure is invoked once per attempt. The final error is returned
unchanged, so call sites match on Error exactly as they would
without retries.
§Errors
Returns the last error once the operation fails with a non-retryable error or the policy’s retries are exhausted.
Trait Implementations§
Source§impl Clone for TimewebClient
impl Clone for TimewebClient
Source§fn clone(&self) -> TimewebClient
fn clone(&self) -> TimewebClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TimewebClient
impl !UnwindSafe for TimewebClient
impl Freeze for TimewebClient
impl Send for TimewebClient
impl Sync for TimewebClient
impl Unpin for TimewebClient
impl UnsafeUnpin for TimewebClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more