Starting a command type.
This commit is contained in:
parent
498612a5c0
commit
41d5f980ef
9
src/mpvctl/command.rs
Normal file
9
src/mpvctl/command.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pub struct Command {
|
||||||
|
command: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Command {
|
||||||
|
pub fn new(command: Vec<String>) -> Self {
|
||||||
|
Command { command: command }
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
mod command;
|
||||||
mod mpvctl;
|
mod mpvctl;
|
||||||
|
|
||||||
pub use mpvctl::MpvCtl;
|
pub use mpvctl::MpvCtl;
|
||||||
|
@ -1 +1,39 @@
|
|||||||
pub struct MpvCtl;
|
use std::collections::HashMap;
|
||||||
|
use std::{collections::BTreeMap, path::Path};
|
||||||
|
use tokio::net::UnixStream;
|
||||||
|
|
||||||
|
use super::command::Command;
|
||||||
|
|
||||||
|
pub struct MpvCtl {
|
||||||
|
socket: UnixStream,
|
||||||
|
next_request_id: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MpvCtl {
|
||||||
|
pub async fn connect<P: AsRef<Path>>(
|
||||||
|
socket_path: P,
|
||||||
|
) -> Result<Self, Box<dyn std::error::Error>> {
|
||||||
|
let socket = UnixStream::connect(socket_path).await?;
|
||||||
|
Ok(MpvCtl {
|
||||||
|
socket,
|
||||||
|
next_request_id: 0,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn grab_request_id(&mut self) -> u64 {
|
||||||
|
let ret = self.next_request_id;
|
||||||
|
self.next_request_id += 1;
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn send_command(&self, cmd: Command) {
|
||||||
|
//
|
||||||
|
// let serialized =
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_client_name(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let request_id = self.grab_request_id();
|
||||||
|
let cmd = Command::new(vec!["client_name".to_string()]);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user