MpvCommand

Trait MpvCommand 

Source
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§

Source

type Data: DeserializeOwned

The response data field type.

Usually serde_json::Value.

Source

type ParsedData

The output of parse_data.

Source

type Error: Error

The error produced while parsing Self::Data.

Required Methods§

Source

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.

Source

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.

Implementors§

Source§

impl MpvCommand for CmdGetVersion

Source§

impl MpvCommand for CmdSeek

Source§

impl MpvCommand for CmdStop

Source§

impl MpvCommand for CmdUnobserveProperty

Source§

impl<'a> MpvCommand for CmdLoadfile<'a>

Source§

impl<P: MpvProperty> MpvCommand for CmdCycleProperty<P>

Source§

impl<P: MpvProperty> MpvCommand for CmdGetProperty<P>

Source§

impl<P: MpvProperty> MpvCommand for CmdObserveProperty<P>

Source§

impl<P: MpvProperty> MpvCommand for CmdSetProperty<P>

Source§

impl<S: AsRef<str>> MpvCommand for CmdRawJsonArgs<S>