pub trait HttpResource<R: for<'de> Deserialize<'de>> {
// Required method
fn path(&self) -> String;
// Provided methods
fn method(&self) -> Method { ... }
fn json(&self) -> Option<String> { ... }
fn path_without_query(&self) -> String { ... }
}
Expand description
Represents an HTTP resource (endpoint)
This is used as a parameter to Scryfall in order to make a request to the api.
Required Methods§
Provided Methods§
Sourcefn json(&self) -> Option<String>
fn json(&self) -> Option<String>
Defines the (optional) json body when requesting the endpoint.
This is useful in cases of POST/PUT/PATCH etc.
By default it is None
.
Sourcefn path_without_query(&self) -> String
fn path_without_query(&self) -> String
Strips the query parameters (if any) from the endpoint path
§Example
use scryfall_sdk_rust::HttpResource;
struct SomeResource;
impl HttpResource<String> for SomeResource {
fn path(&self) -> String {
"somepath?aQueryParam=123".into()
}
}
let res = SomeResource;
assert_eq!("somepath", res.path_without_query())