pub struct IpcServer { /* private fields */ }Expand description
Listens on a local socket and dispatches connections to an IpcHandler.
Uses Unix domain sockets on Linux/macOS and named pipes on Windows.
The server shuts down cleanly when the provided CancellationToken is cancelled.
Implementations§
Source§impl IpcServer
impl IpcServer
Sourcepub fn with_path(path: impl Into<String>) -> Self
pub fn with_path(path: impl Into<String>) -> Self
Create a server bound to a custom socket path.
Prefer IpcServer::default in production code.
This method exists primarily for test isolation.
Sourcepub async fn serve<H: IpcHandler>(
&self,
handler: Arc<H>,
token: CancellationToken,
) -> Result<()>
pub async fn serve<H: IpcHandler>( &self, handler: Arc<H>, token: CancellationToken, ) -> Result<()>
Start accepting connections until token is cancelled.
Removes a stale socket file at startup on Unix. On shutdown, the socket file is removed again so subsequent starts are clean.
§Errors
Returns [IpcError] if the socket cannot be bound or if an
unrecoverable I/O error occurs during the accept loop.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IpcServer
impl RefUnwindSafe for IpcServer
impl Send for IpcServer
impl Sync for IpcServer
impl Unpin for IpcServer
impl UnsafeUnpin for IpcServer
impl UnwindSafe for IpcServer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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