hyprshell_core_lib/binds/
transfer.rs

1use crate::transfer::TransferType;
2use std::env;
3
4/// # Panics
5/// if the current executable couldn't be found
6#[must_use]
7pub fn get_hyprshell_path() -> String {
8    env::current_exe()
9        .expect("Current executable not found")
10        .display()
11        .to_string()
12        .replace("(deleted)", "")
13}
14
15/// # Panics
16/// if the transfer could not be serialized into a string
17#[must_use]
18pub fn generate_transfer_socat(transfer: &TransferType) -> String {
19    format!(
20        r"{} socat '{}'",
21        get_hyprshell_path(),
22        generate_transfer(transfer)
23    )
24}
25
26/// # Panics
27/// if the transfer could not be serialized into a string
28#[must_use]
29pub fn generate_transfer(transfer: &TransferType) -> String {
30    serde_json::to_string(transfer).expect("serialize transfer")
31}