pub struct Socket { /* private fields */ }
Expand description
Helper for blocking communication over the niri socket.
This struct is used to communicate with the niri IPC server. It handles the socket connection and serialization/deserialization of messages.
Implementations§
source§impl Socket
impl Socket
sourcepub fn connect() -> Result<Self>
pub fn connect() -> Result<Self>
Connects to the default niri IPC socket.
This is equivalent to calling Self::connect_to
with the path taken from the
SOCKET_PATH_ENV
environment variable.
sourcepub fn connect_to(path: impl AsRef<Path>) -> Result<Self>
pub fn connect_to(path: impl AsRef<Path>) -> Result<Self>
Connects to the niri IPC socket at the given path.
sourcepub fn send(
self,
request: Request,
) -> Result<(Reply, impl FnMut() -> Result<Event>)>
pub fn send( self, request: Request, ) -> Result<(Reply, impl FnMut() -> Result<Event>)>
Sends a request to niri and returns the response.
Return values:
Ok(Ok(response))
: successfulResponse
from niriOk(Err(message))
: error message from niriErr(error)
: error communicating with niri
This method also returns a blocking function that you can call to keep reading Event
s
after requesting an EventStream
. This function is not useful
otherwise.
Auto Trait Implementations§
impl Freeze for Socket
impl RefUnwindSafe for Socket
impl Send for Socket
impl Sync for Socket
impl Unpin for Socket
impl UnwindSafe for Socket
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more