Trait odoo_api::jsonrpc::OdooApiMethod
source · pub trait OdooApiMethodwhere
Self: Sized + Serialize + Debug + PartialEq,{
type Response: Sized + Serialize + DeserializeOwned + Debug + PartialEq + TryFrom<String> + TryFrom<Value>;
fn describe_odoo_api_method(&self) -> (&'static str, &'static str);
fn parse_json_response(
&self,
json_data: &str
) -> Result<OdooApiResponse<Self>>;
}
Expand description
A trait implemented by the “request” structs
This trait serves a few purposes:
- Create a link between the request and response structs (e.g.,
Execute
andExecuteResponse
) - Describe the request (e.g. service:
object
, method:execute
) - Provide a response-parsing function
Required Associated Types§
Required Methods§
sourcefn describe_odoo_api_method(&self) -> (&'static str, &'static str)
fn describe_odoo_api_method(&self) -> (&'static str, &'static str)
Describes the Odoo API method (including the service)
The Odoo API is split into “services” and “methods”.
For example, his function is responsible for returning the "common"
and "version"
below:
{
"jsonrpc": "2.0",
"method": "call",
"params": {
// the "service"
"service": "common",
// the "method"
"method": "version",
"args": []
}
}
sourcefn parse_json_response(&self, json_data: &str) -> Result<OdooApiResponse<Self>>
fn parse_json_response(&self, json_data: &str) -> Result<OdooApiResponse<Self>>
Parse some JSON string data into an OdooApiResponse
object
Internally, OdooApiResponse
uses the Response
associated type to
decide how to deserialize the JSON data.