pub trait RestEndpoint {
// Required methods
fn method(&self) -> Method;
fn endpoint(&self) -> Cow<'static, str>;
fn service_type(&self) -> ServiceType;
// Provided methods
fn parameters(&self) -> QueryParams<'_> { ... }
fn body(&self) -> Result<Option<(&'static str, Vec<u8>)>, BodyError> { ... }
fn response_key(&self) -> Option<Cow<'static, str>> { ... }
fn response_list_item_key(&self) -> Option<Cow<'static, str>> { ... }
fn response_headers(&self) -> HashMap<&str, &str> { ... }
fn request_headers(&self) -> Option<&HeaderMap> { ... }
fn api_version(&self) -> Option<ApiVersion> { ... }
}Expand description
A trait for providing the necessary information for a single REST API endpoint.
Required Methods§
Sourcefn service_type(&self) -> ServiceType
fn service_type(&self) -> ServiceType
The endpoint service type.
Provided Methods§
Sourcefn parameters(&self) -> QueryParams<'_>
fn parameters(&self) -> QueryParams<'_>
Query parameters for the endpoint.
Sourcefn body(&self) -> Result<Option<(&'static str, Vec<u8>)>, BodyError>
fn body(&self) -> Result<Option<(&'static str, Vec<u8>)>, BodyError>
The body for the endpoint.
Returns the Content-Type header for the data as well as the data itself.
Sourcefn response_key(&self) -> Option<Cow<'static, str>>
fn response_key(&self) -> Option<Cow<'static, str>>
Returns response key under which the data is expected
Sourcefn response_list_item_key(&self) -> Option<Cow<'static, str>>
fn response_list_item_key(&self) -> Option<Cow<'static, str>>
Returns response key under which the list item data is expected (i.e. {"list": ["item":{}, "item": {}}
Sourcefn response_headers(&self) -> HashMap<&str, &str>
fn response_headers(&self) -> HashMap<&str, &str>
Returns map of headers to capture from the endpoint response to the names in the target result struct.
Sourcefn request_headers(&self) -> Option<&HeaderMap>
fn request_headers(&self) -> Option<&HeaderMap>
Returns headers to be set into the request
Sourcefn api_version(&self) -> Option<ApiVersion>
fn api_version(&self) -> Option<ApiVersion>
Returns required API version
Noneis interpreted as default versionApiVersion {0, 0}is interpreted as explicitly unversioned API
Default is to try to determine version from the url (first segment)