pub trait MpvCommand: MpvCommandRaw {
type Data: DeserializeOwned;
type ParsedData;
type Error: Error;
// Required methods
fn write_args(&self, w: impl Write) -> Result<()>;
fn parse_data(
&self,
data: Self::Data,
) -> Result<Self::ParsedData, Self::Error>;
}Expand description
Trait for mpv JSON command definition.
Command model:
{ "command": ["name", "arg1", "arg2"], "request_id"?: 123 }Required Associated Types§
Sourcetype Data: DeserializeOwned
type Data: DeserializeOwned
The response data field type.
Usually serde_json::Value.
Sourcetype ParsedData
type ParsedData
The output of parse_data.
Required Methods§
Sourcefn write_args(&self, w: impl Write) -> Result<()>
fn write_args(&self, w: impl Write) -> Result<()>
Formats command arguments into a stream.
The arguments must be formatted as a valid JSON array with the enclosing paren ([]) symbols removed.
For example to send { "command": ["name", "arg1", "arg2"], "request_id"?: 123 } this method should
write into the stream "name", "arg1", "arg2".
This method is only called from the default implementation of write_raw.
Sourcefn parse_data(&self, data: Self::Data) -> Result<Self::ParsedData, Self::Error>
fn parse_data(&self, data: Self::Data) -> Result<Self::ParsedData, Self::Error>
Parses data from a response “data” field. The data is guaranteed to be a valid JSON value.
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.