Starting a command type.

master
Tom Alexander 2 years ago
parent 498612a5c0
commit 41d5f980ef
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -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;
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…
Cancel
Save