Add find_socket() to Magpie
This commit is contained in:
parent
0d4eb5d188
commit
4007c40ba6
|
@ -4,7 +4,7 @@
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::path::PathBuf;
|
use std::path::{PathBuf, Path};
|
||||||
|
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -211,6 +211,16 @@ impl<T: Read, I: DeserializeOwned, O> Messenger<T, I, O> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Acquires the path to the Magpie socket.
|
||||||
|
///
|
||||||
|
/// Currently only joins XDG_RUNTIME_DIR with [MAGPIE_SOCK].
|
||||||
|
pub fn find_socket() -> PathBuf {
|
||||||
|
let sock_dir = std::env::var("XDG_RUNTIME_DIR").expect("XDG_RUNTIME_DIR not set");
|
||||||
|
let sock_dir = Path::new(&sock_dir);
|
||||||
|
let sock_path = sock_dir.join(MAGPIE_SOCK);
|
||||||
|
sock_path
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
mod async_messages {
|
mod async_messages {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in New Issue