pub struct Client {
inner: Rc<Inner>,
}Expand description
Client for making requests to pubhubs servers and hubs; cheaply clonable
Fields§
§inner: Rc<Inner>Implementations§
Source§impl Client
impl Client
Sourcepub async fn get_constellation(&self, url: &Url) -> Result<ConstellationOrId>
pub async fn get_constellation(&self, url: &Url) -> Result<ConstellationOrId>
Retrieves Constellation from specified url, waiting for it to be set.
Sourcepub async fn try_get_stable_constellation(
&self,
phc_url: &Url,
) -> Result<Option<Constellation>>
pub async fn try_get_stable_constellation( &self, phc_url: &Url, ) -> Result<Option<Constellation>>
Retrieves Constellation from all servers, and checks they coincide; returns None when
there’s a disagreement.
Source§impl Client
impl Client
Sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Returns the underlying awc::Client, for making raw HTTP requests.
Sourcepub fn query_with_retry<EP: EndpointDetails + 'static, BU, BR>(
&self,
server_url: BU,
req: BR,
) -> impl Future<Output = EP::ResponseType> + use<EP, BU, BR>
pub fn query_with_retry<EP: EndpointDetails + 'static, BU, BR>( &self, server_url: BU, req: BR, ) -> impl Future<Output = EP::ResponseType> + use<EP, BU, BR>
Like Client::query, but retries the query when it fails with a crate::api::ErrorInfo::retryable ErrorCode.
When A queries B and B queries C, the B should, in general, not use
Client::query_with_retry, but let A manage retries. This prevents A’s request from hanging
without any explanation.
Unlike Client::query, the future returned by query_with_retry borrows server_url
and req. (It does not borrow self.)
The borrowing of server_url and req by the returned future has the unfortunate
side-effect that when the future is passed to, say, tokio::spawn, server_url
and req are forced to have the 'static lifetime. In such cases it’s easiest to pass
server_url and req not by reference, but by value - whence the use of the Borrow<T> trait,
which is implemented both by T and &T.
Sourcepub fn query<'a, EP: EndpointDetails + 'static>(
&self,
server_url: &'a Url,
req: impl Borrow<EP::RequestType> + 'a,
) -> QuerySetup<EP, &'a Url, impl Borrow<EP::RequestType>, HashMap<&'static str, Cow<'a, str>>, HeaderValue>
pub fn query<'a, EP: EndpointDetails + 'static>( &self, server_url: &'a Url, req: impl Borrow<EP::RequestType> + 'a, ) -> QuerySetup<EP, &'a Url, impl Borrow<EP::RequestType>, HashMap<&'static str, Cow<'a, str>>, HeaderValue>
Sends a request to EP endpoint at server_url.
async fn query_inner<EP: EndpointDetails + 'static>( self, url: Url, req: SendClientRequest, quiet: bool, ) -> Result<EP::ResponseType>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl !Send for Client
impl !Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
impl !UnwindSafe for Client
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more