pub trait Endpoint {
type Response: for<'a> Deserialize<'a> + Debug;
// Required methods
fn method(&self) -> Method;
fn path(&self) -> String;
// Provided methods
fn query(&self) -> Option<String> { ... }
fn headers(&self) -> Option<HeaderMap> { ... }
fn body(&self) -> Option<String> { ... }
fn url(&self, base_url: &Url) -> Url { ... }
fn content_type(&self) -> 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 Response.
Required Associated Types§
type Response: for<'a> Deserialize<'a> + Debug
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 headers(&self) -> Option<HeaderMap>
fn headers(&self) -> Option<HeaderMap>
The set of headers to be sent with request. Defaults to None.
Implementors should inline this.
Sourcefn body(&self) -> Option<String>
fn body(&self) -> Option<String>
The HTTP body associated with this endpoint. If not implemented, defaults to None.
Implementors should inline this.
Sourcefn url(&self, base_url: &Url) -> Url
fn url(&self, base_url: &Url) -> Url
Builds and returns a formatted full URL, including query, for the endpoint.
Implementors should generally not override this.
Sourcefn content_type(&self) -> Cow<'static, str>
fn content_type(&self) -> Cow<'static, str>
If body is populated, indicates the body MIME type (defaults to JSON).
Implementors generally do not need to override this.