latchshot 0.2.5

A lightweight yet intelligent window-aware screenshot tool
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::io::{Read, Write};
use std::os::unix::net::UnixStream;
use std::path::Path;

use anyhow::Result;
use serde::de::DeserializeOwned;

pub(super) fn request_json<T: DeserializeOwned>(path: &Path, command: &[u8]) -> Result<T> {
    let mut socket = UnixStream::connect(path)?;
    socket.write_all(command)?;

    let mut reply = Vec::new();
    socket.read_to_end(&mut reply)?;

    Ok(serde_json::from_slice(&reply)?)
}