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

source

pub fn new(endpoint: impl AsRef<Address>) -> Self

Constructor for the ProxyClient.

Note that no connection is made yet; this is done lazily.

§Arguments
  • endpoint: The remote proxy endpoint to connect to.
§Returns

A new ProxyClient instance.

source

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.

source

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: A Serializeable 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.

source

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.

source

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.

source

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§

source§

impl Debug for ProxyClient

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T