pub struct DaemonServer { /* private fields */ }Expand description
Daemon-side socket server.
Binds a Unix domain socket, accepts client connections, and broadcasts file-change events and status updates to all connected clients.
Implementations§
Source§impl DaemonServer
impl DaemonServer
Sourcepub fn new(root: &Path) -> Result<Self, DaemonSockError>
pub fn new(root: &Path) -> Result<Self, DaemonSockError>
Create and bind a new daemon socket server for the given watched root.
The socket path is derived from the canonical root (see socket_path).
Any existing socket file at the path is removed before binding.
§Errors
Returns an error if the parent directory cannot be created or the socket cannot be bound.
Sourcepub fn start(&mut self) -> Result<(), DaemonSockError>
pub fn start(&mut self) -> Result<(), DaemonSockError>
Start the accept-and-read loop in a background thread.
After calling start(), the server will accept new connections and
respond to client queries automatically. Call DaemonServer::broadcast
from the main loop to push events to all connected clients.
§Errors
Returns an error if the listener cannot be cloned, the accept thread cannot be spawned, or file descriptor operations fail.
Sourcepub fn broadcast(&self, msg: &ServerMessage)
pub fn broadcast(&self, msg: &ServerMessage)
Broadcast a server message to all connected clients.
Disconnected clients are automatically removed. The message is serialized once and written to each client with a short write timeout to prevent a slow consumer from blocking the daemon.
Sourcepub fn set_status(&self, daemon_status: &DaemonStatus, files_count: usize)
pub fn set_status(&self, daemon_status: &DaemonStatus, files_count: usize)
Update the daemon status and file count (reflected in subsequent broadcasts and query responses).
Sourcepub fn notify_changes(&self, changes: Vec<FileChange>, files_count: usize)
pub fn notify_changes(&self, changes: Vec<FileChange>, files_count: usize)
Record a file-change batch in the history buffer and broadcast it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DaemonServer
impl !RefUnwindSafe for DaemonServer
impl Send for DaemonServer
impl Sync for DaemonServer
impl Unpin for DaemonServer
impl UnsafeUnpin for DaemonServer
impl !UnwindSafe for DaemonServer
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more