pub trait PandoraJsonApiRequest: Serialize {
type Response: Debug + DeserializeOwned;
type Error: Debug + From<Error> + From<Error> + From<JsonError> + Send;
// Required method
fn get_method(&self) -> String;
// Provided methods
fn get_json(&self) -> Result<Value, Self::Error> { ... }
fn encrypt_request(&self) -> bool { ... }
fn request(
&self,
session: &mut PandoraSession,
) -> Result<RequestBuilder, Self::Error> { ... }
fn response<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut PandoraSession,
) -> Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Expand description
A trait for accessing information and capabilities specific to each Pandora JSON API call, including the method name, the json body content, and whether the body content should be encrypted before transmission.
It also includes two convenience methods for submitting the request.
Required Associated Types§
Sourcetype Response: Debug + DeserializeOwned
type Response: Debug + DeserializeOwned
The type that the json response will be deserialized to.
Required Methods§
Sourcefn get_method(&self) -> String
fn get_method(&self) -> String
Returns the name of the Pandora JSON API call in the form that it must appear when making that call.
Provided Methods§
Sourcefn get_json(&self) -> Result<Value, Self::Error>
fn get_json(&self) -> Result<Value, Self::Error>
Returns the root json Value that should be serialized into the body of the API call.
Sourcefn encrypt_request(&self) -> bool
fn encrypt_request(&self) -> bool
Whether the json body of the API call is expected to be encrypted before transmission.
Sourcefn request(
&self,
session: &mut PandoraSession,
) -> Result<RequestBuilder, Self::Error>
fn request( &self, session: &mut PandoraSession, ) -> Result<RequestBuilder, Self::Error>
Generate an HTTP request that, when send() is called on it, will submit the built request.
Sourcefn response<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut PandoraSession,
) -> Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn response<'life0, 'life1, 'async_trait>(
&'life0 self,
session: &'life1 mut PandoraSession,
) -> Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Build the request, submit it, and extract the response content from the body json, and deserialize it into the Self::Response type.
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.