Request

Struct Request 

Source
pub struct Request {
    pub config: Config,
    pub client_info: ClientInfo,
    pub handles: Handles,
    pub operation: Operation,
}
Expand description

Represents a request to the Volcengine API.

This struct holds all the necessary components for making a request to the Volcengine API. It contains the configuration, client information, operation details, and handles to manage the request operations. The struct is designed to encapsulate the various elements required for interacting with the Volcengine service, ensuring that all necessary data is included when making the API request.

Fields§

§config: Config

Configuration settings for the request.

This field contains the configuration settings necessary to make the request. It might include things like authentication details, API keys, endpoint URLs, or other settings related to the request environment.

§client_info: ClientInfo

Information about the client making the request.

This field contains details about the client or the system that is making the request. This could include information such as the client ID, version, operating system, and any other metadata relevant to identifying the client.

§handles: Handles

Handles for managing request operations.

This field provides handles to manage the lifecycle and execution of the request. These could include handles for making retries, timeouts, managing API rate limits, or other request-related operations.

§operation: Operation

Operation details for the request.

This field holds the specific operation that the request will perform. It might include data like the action or API method being called, parameters for that action, or other relevant details for the request’s operation.

Implementations§

Source§

impl Request

Implementation of the Request struct, providing methods to construct and manage a request.

This block of code defines methods associated with the Request struct, such as the builder method. The Request struct represents an API request to the Volcengine API and is composed of various components including the configuration, client information, handles, and operation. The methods in this impl block allow for the creation and management of these components, making it easier to construct and send requests.

The builder pattern is used here, allowing you to step-by-step configure the components of the Request before it is finalized and sent. This is especially useful for building requests with varying components.

§Example Usage

let request = Request::builder()
    .config(config)
    .client_info(client_info)
    .handles(handles)
    .operation(operation)
    .build();
Source

pub fn builder() -> RequestBuilder

Constructs a new RequestBuilder instance for building a Request.

This method provides a fluent interface for constructing a Request step by step. It allows for setting the configuration, client information, handles, and operation before finalizing and creating the actual Request object. This is useful when you need to build a request with optional components that may vary between requests.

§Returns

Returns a RequestBuilder that enables the construction of a Request object. The builder can be used to set each of the fields in the Request struct, allowing for customization of the request before it is finalized.

§Example
let request = Request::builder()
    .config(config)
    .client_info(client_info)
    .handles(handles)
    .operation(operation)
    .build();

Trait Implementations§

Source§

impl Clone for Request

Source§

fn clone(&self) -> Request

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Request

Source§

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

Formats the value using the given formatter. Read more
Source§

impl RequestVolcengine for Request

Implementation of the RequestVolcengine trait for the Request struct.

This block provides methods for formatting the request into a HashMap and sending an API request. The methods implement the functionality needed to interact with the Volcengine API. The Request struct is adapted to handle serialization and request sending according to the Volcengine API’s requirements.

The methods in this implementation allow for easy conversion of the request data to a format expected by the Volcengine API and also provide a way to send the request over HTTP using the reqwest library.

§Example Usage

let request = Request::builder()
    .config(config)
    .client_info(client_info)
    .handles(handles)
    .operation(operation)
    .build();

let result = request.send(api_request);
Source§

fn format_request_to_hashmap<T: Serialize>( request: &T, ) -> HashMap<String, String>

Formats the request into a HashMap<String, String>.

§Parameters
  • request: A reference to a serializable object.
§Returns

Returns a HashMap<String, String> representation of the request, filtering out null or empty values.

Source§

async fn send<T: ApiRequest>(&self, request: T) -> Result<Response, Error>

Sends the request to the Volcengine API.

§Parameters
  • request: An instance implementing the ApiRequest trait.
§Returns

Returns a Result containing the reqwest::Response or an error.

This function sends the request and waits for the API response asynchronously.

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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,