pub trait RemoteResource {
type Query: QueryField + ValueValidator;
type Field: QueryField;
// Required methods
fn context_with<Q, F>(&self, data: Option<Vec<Param>>) -> Context
where Q: QueryField + ValueValidator,
F: QueryField;
fn handle_or<R, E>(
&self,
response: ApiResult<ResponseContent>,
) -> ApiResult<R>
where R: for<'de> Deserialize<'de>,
E: FallbackResponse;
fn invoke<'life0, 'async_trait>(
&'life0 self,
action: impl 'async_trait + Into<String> + Clone + Send,
data: Option<Vec<Param>>,
) -> Pin<Box<dyn Future<Output = ApiResult<ResponseContent>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn invoke_with<'life0, 'async_trait, Q, F>(
&'life0 self,
action: impl 'async_trait + Into<String> + Clone + Send,
data: Option<Vec<Param>>,
) -> Pin<Box<dyn Future<Output = ApiResult<ResponseContent>> + Send + 'async_trait>>
where Q: QueryField + ValueValidator + 'async_trait,
F: QueryField + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn context(&self, params: Option<Vec<Param>>) -> Context { ... }
fn handle<R>(&self, response: ApiResult<ResponseContent>) -> ApiResult<R>
where R: for<'de> Deserialize<'de> { ... }
}Expand description
Trait for working with request-response cycle using HTTP methods like GET, POST, PUT, PATCH, and DELETE against resource URLs that return structured data
Required Associated Types§
Sourcetype Query: QueryField + ValueValidator
type Query: QueryField + ValueValidator
Query field type used for request building
Sourcetype Field: QueryField
type Field: QueryField
Field list type used for response selection
Required Methods§
Sourcefn context_with<Q, F>(&self, data: Option<Vec<Param>>) -> Context
fn context_with<Q, F>(&self, data: Option<Vec<Param>>) -> Context
Build context for endpoint paths using explicit query and field types
Sourcefn handle_or<R, E>(&self, response: ApiResult<ResponseContent>) -> ApiResult<R>where
R: for<'de> Deserialize<'de>,
E: FallbackResponse,
fn handle_or<R, E>(&self, response: ApiResult<ResponseContent>) -> ApiResult<R>where
R: for<'de> Deserialize<'de>,
E: FallbackResponse,
Handle a response from an endpoint request, trying to parse as R first,
then falling back to E on parse failure to surface a richer error message
Sourcefn invoke<'life0, 'async_trait>(
&'life0 self,
action: impl 'async_trait + Into<String> + Clone + Send,
data: Option<Vec<Param>>,
) -> Pin<Box<dyn Future<Output = ApiResult<ResponseContent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
action: impl 'async_trait + Into<String> + Clone + Send,
data: Option<Vec<Param>>,
) -> Pin<Box<dyn Future<Output = ApiResult<ResponseContent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send data to the endpoint and receive a response asynchronously
Sourcefn invoke_with<'life0, 'async_trait, Q, F>(
&'life0 self,
action: impl 'async_trait + Into<String> + Clone + Send,
data: Option<Vec<Param>>,
) -> Pin<Box<dyn Future<Output = ApiResult<ResponseContent>> + Send + 'async_trait>>where
Q: QueryField + ValueValidator + 'async_trait,
F: QueryField + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn invoke_with<'life0, 'async_trait, Q, F>(
&'life0 self,
action: impl 'async_trait + Into<String> + Clone + Send,
data: Option<Vec<Param>>,
) -> Pin<Box<dyn Future<Output = ApiResult<ResponseContent>> + Send + 'async_trait>>where
Q: QueryField + ValueValidator + 'async_trait,
F: QueryField + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Send data to the endpoint and receive a response asynchronously using explicit query/field types
Provided Methods§
Sourcefn context(&self, params: Option<Vec<Param>>) -> Context
fn context(&self, params: Option<Vec<Param>>) -> Context
Build context for endpoint paths using the associated query and field types
Sourcefn handle<R>(&self, response: ApiResult<ResponseContent>) -> ApiResult<R>where
R: for<'de> Deserialize<'de>,
fn handle<R>(&self, response: ApiResult<ResponseContent>) -> ApiResult<R>where
R: for<'de> Deserialize<'de>,
Handle a response from an endpoint request
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".