Struct brane_prx::client::ProxyClient
source · pub struct ProxyClient { /* private fields */ }
Expand description
Defines a ProxyClient, which remembers the paths stored and seamlessly translates between them.
Implementations§
source§impl ProxyClient
impl ProxyClient
sourcepub async fn get(
&self,
address: impl AsRef<str>,
tls: Option<NewPathRequestTlsOptions>,
) -> Result<Result<Response, Error>, Error>
pub async fn get( &self, address: impl AsRef<str>, tls: Option<NewPathRequestTlsOptions>, ) -> Result<Result<Response, Error>, Error>
Sends a GET-request to the given address/path.
§Arguments
address
: The address to send the request to.tls
: The TLS settings of the remote proxy to use for this request.
§Returns
The result of the request, as a Result<reqwest::Response, reqwest::Error>
.
§Errors
This function errors if we fail to reserve any new paths if necessary.
sourcepub async fn get_with_body(
&self,
address: impl AsRef<str>,
tls: Option<NewPathRequestTlsOptions>,
body: &(impl ?Sized + Serialize),
) -> Result<Result<Response, Error>, Error>
pub async fn get_with_body( &self, address: impl AsRef<str>, tls: Option<NewPathRequestTlsOptions>, body: &(impl ?Sized + Serialize), ) -> Result<Result<Response, Error>, Error>
Sends a GET-request with a JSON body to the given address/path.
§Arguments
address
: The address to send the request to.tls
: The TLS settings of the remote proxy to use for this request.body
: ASerialize
able body to send along.
§Returns
The result of the request, as a Result<reqwest::Response, reqwest::Error>
.
§Errors
This function errors if we fail to reserve any new paths if necessary.
sourcepub async fn execute(
&self,
client: Client,
request: impl Into<Request>,
tls: Option<NewPathRequestTlsOptions>,
) -> Result<Result<Response, Error>, Error>
pub async fn execute( &self, client: Client, request: impl Into<Request>, tls: Option<NewPathRequestTlsOptions>, ) -> Result<Result<Response, Error>, Error>
Sends the given reqwest
request to the given address/path using the given client.
§Arguments
client
: The client to perform the actual request itself.request
: The request to send. Already carries the address to which we send it.tls
: The TLS settings to use for this request.
§Returns
The result of the request, as a Result<reqwest::Response, reqwest::Error>
.
§Errors
This function errors if we fail to reserve any new paths if necessary.
sourcepub async fn get_package_index(
&self,
address: impl AsRef<str>,
) -> Result<Result<PackageIndex, Error>, Error>
pub async fn get_package_index( &self, address: impl AsRef<str>, ) -> Result<Result<PackageIndex, Error>, Error>
Requests the package index from the brane-api
service at the given endpoint.
§Arguments
address
: The endpoint (including path) to fetch the package index from.
§Returns
The result of the request, as a Result<PackageIndex, brane_tsk::api::Error>
.
§Errors
This function errors if we fail to reserve any new paths if necessary.
sourcepub async fn connect_to_job(
&self,
address: impl AsRef<str>,
) -> Result<Result<JobServiceClient, JobServiceError>, Error>
pub async fn connect_to_job( &self, address: impl AsRef<str>, ) -> Result<Result<JobServiceClient, JobServiceError>, Error>
Connects to the given brane-job
service using gRPC.
This effectively creates a JobServiceClient, but through the proxy node.
§Arguments
address
: The address of the remote to connect to.
§Returns
The result of the connection, as a Result<JobServiceClient, tonic::transport::Error>
.
§Errors
This function errors if we fail to reserve any new paths if necessary.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ProxyClient
impl RefUnwindSafe for ProxyClient
impl Send for ProxyClient
impl Sync for ProxyClient
impl Unpin for ProxyClient
impl UnwindSafe for ProxyClient
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request