pub trait EndpointSpec {
type JsonResponse: ApiResult;
type ResponseType;
const IS_RAW_BODY: bool = false;
// Required methods
fn method(&self) -> Method;
fn path(&self) -> String;
// Provided methods
fn query(&self) -> Option<String> { ... }
fn body(&self) -> Option<RequestBody<'_>> { ... }
fn url(&self, environment: &Environment) -> Url { ... }
fn content_type(&self) -> Option<Cow<'static, str>> { ... }
}Expand description
Represents a specification for an API call that can be built into an HTTP request and sent. New endpoints should implement this trait.
If the request succeeds, the call will resolve to a ResultType.
Provided Associated Constants§
Sourceconst IS_RAW_BODY: bool = false
const IS_RAW_BODY: bool = false
If the body of the response is raw bytes (Vectrue. Defaults to false.
Required Associated Types§
Sourcetype JsonResponse: ApiResult
type JsonResponse: ApiResult
The JSON response type for this endpoint, if any.
For endpoints that return either raw bytes or nothing, this should be ().
Sourcetype ResponseType
type ResponseType
The final response type for this endpoint.
For endpoints that return raw bytes, this should be Vec<u8>.
For endpoints that return JSON, this should be ApiSuccess<Self::JsonResponse>.
Required Methods§
Provided Methods§
Sourcefn query(&self) -> Option<String>
fn query(&self) -> Option<String>
The url-encoded query string associated with this endpoint. Defaults to None.
Implementors should inline this.
Sourcefn body(&self) -> Option<RequestBody<'_>>
fn body(&self) -> Option<RequestBody<'_>>
The HTTP body associated with this endpoint. If not implemented, defaults to None.
Implementors should inline this.
Sourcefn url(&self, environment: &Environment) -> Url
fn url(&self, environment: &Environment) -> Url
Builds and returns a formatted full URL, including query, for the endpoint.
Implementors should generally not override this.
Sourcefn content_type(&self) -> Option<Cow<'static, str>>
fn content_type(&self) -> Option<Cow<'static, str>>
If body is populated, indicates the body MIME type (defaults to JSON).
Implementors generally do not need to override this.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.