8c98c00549
Gate the unix-socket server, systemd activation, and the socket-serving run() behind a new default socket-api feature, with required-features on the binary. The core modules (daemon, store, transfer, discovery, meta) stay feature-free, so platforms without a daemon model (iOS — redoal ADR-0012) can embed Daemon directly via cargo check -p varde-daemon --no-default-features. Also cfg-gate the abstract-socket branch of sd_notify to Linux: abstract socket names don't exist elsewhere, and this was the one spot keeping varde-daemon from compiling on macOS at all. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
31 lines
934 B
Rust
31 lines
934 B
Rust
//! varde-daemon library surface.
|
|
//!
|
|
//! The daemon is a binary, but its internals are exposed as a library so
|
|
//! integration tests can run real daemons in-process on ephemeral sockets.
|
|
|
|
pub mod config;
|
|
pub mod daemon;
|
|
pub mod discovery;
|
|
pub mod dscp;
|
|
pub mod meta;
|
|
pub mod metered;
|
|
#[cfg(feature = "socket-api")]
|
|
pub mod server;
|
|
pub mod shaped;
|
|
pub mod store;
|
|
pub mod transfer;
|
|
|
|
#[cfg(feature = "socket-api")]
|
|
use anyhow::Result;
|
|
|
|
/// Run a daemon with the given config until the future is dropped or the
|
|
/// listener fails. The socket is bound before the accept loop starts, so
|
|
/// once this future has been polled the socket path exists.
|
|
#[cfg(feature = "socket-api")]
|
|
pub async fn run(config: config::Config) -> Result<()> {
|
|
let socket_path = config.socket_path.clone();
|
|
let daemon = daemon::Daemon::open(config).await?;
|
|
let listener = server::bind_socket(&socket_path)?;
|
|
server::serve(listener, daemon).await
|
|
}
|