pub struct IpcSocket { /* private fields */ }Expand description
An exclusively owned, bound Unix-domain IPC socket.
The advisory lock file serializes daemon startup so two processes can never both decide that the socket is stale. The guard removes the socket on drop, but only when the path still refers to the exact inode created by this instance, so a successor’s socket is never unlinked.
Implementations§
Source§impl IpcSocket
impl IpcSocket
Sourcepub async fn acquire<P: AsRef<Path>>(path: P) -> Result<Self, IpcError>
pub async fn acquire<P: AsRef<Path>>(path: P) -> Result<Self, IpcError>
Acquires the socket path and binds a listener.
A live socket is reported as IpcError::AlreadyRunning. A stale
socket (connection refused) is removed and replaced. Any other kind
of filesystem object at the path is left untouched and rejected.
pub fn path(&self) -> &Path
Sourcepub async fn serve<F, Fut>(self, handler: F) -> Result<(), IpcError>where
F: Fn(IpcCommand) -> Fut + Send + Sync + 'static,
Fut: Future<Output = IpcResponse> + Send + 'static,
pub async fn serve<F, Fut>(self, handler: F) -> Result<(), IpcError>where
F: Fn(IpcCommand) -> Fut + Send + Sync + 'static,
Fut: Future<Output = IpcResponse> + Send + 'static,
Serves IPC connections until the listener fails.
At most [MAX_CONCURRENT_CONNECTIONS] connections are handled at
once. Accepting is gated by the semaphore, so a flood backpressures in
the kernel backlog instead of allocating unbounded tasks.
Sourcepub fn spawn<F, Fut>(self, handler: F)where
F: Fn(IpcCommand) -> Fut + Send + Sync + 'static,
Fut: Future<Output = IpcResponse> + Send + 'static,
pub fn spawn<F, Fut>(self, handler: F)where
F: Fn(IpcCommand) -> Fut + Send + Sync + 'static,
Fut: Future<Output = IpcResponse> + Send + 'static,
Runs IpcSocket::serve on a detached task.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for IpcSocket
impl RefUnwindSafe for IpcSocket
impl Send for IpcSocket
impl Sync for IpcSocket
impl Unpin for IpcSocket
impl UnsafeUnpin for IpcSocket
impl UnwindSafe for IpcSocket
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.