pub struct SystemdAdapterImpl { /* private fields */ }Expand description
Linux systemd adapter.
Manages daemons as systemd transient units via systemd-run and systemctl.
§Requirements
- Linux with systemd (version 232+)
- User must have permissions for
systemd-run --useror root for system units
§Example
ⓘ
use duende_core::adapters::SystemdAdapter;
use duende_core::PlatformAdapter;
let adapter = SystemdAdapter::user();
let handle = adapter.spawn(my_daemon).await?;Implementations§
Source§impl SystemdAdapter
impl SystemdAdapter
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new systemd adapter with default settings (user mode).
Alias for user() for API compatibility.
Sourcepub fn system() -> Self
pub fn system() -> Self
Creates a new systemd adapter for system-level daemons.
Requires root or appropriate polkit permissions.
Sourcepub fn user() -> Self
pub fn user() -> Self
Creates a new systemd adapter for user-level daemons.
Uses systemd --user session, no root required.
Sourcepub fn with_unit_dir(unit_dir: PathBuf, user_mode: bool) -> Self
pub fn with_unit_dir(unit_dir: PathBuf, user_mode: bool) -> Self
Creates adapter with custom unit directory.
Sourcepub const fn is_user_mode(&self) -> bool
pub const fn is_user_mode(&self) -> bool
Returns whether running in user mode.
Source§impl SystemdAdapter
impl SystemdAdapter
Sourcepub async fn stop(&self, unit_name: &str) -> PlatformResult<()>
pub async fn stop(&self, unit_name: &str) -> PlatformResult<()>
Stops a systemd unit.
Sourcepub async fn reset_failed(&self, unit_name: &str) -> PlatformResult<()>
pub async fn reset_failed(&self, unit_name: &str) -> PlatformResult<()>
Resets a failed systemd unit.
Trait Implementations§
Source§impl Default for SystemdAdapter
impl Default for SystemdAdapter
Source§impl PlatformAdapter for SystemdAdapter
impl PlatformAdapter for SystemdAdapter
Source§fn spawn<'life0, 'async_trait>(
&'life0 self,
daemon: Box<dyn Daemon>,
) -> Pin<Box<dyn Future<Output = PlatformResult<DaemonHandle>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn spawn<'life0, 'async_trait>(
&'life0 self,
daemon: Box<dyn Daemon>,
) -> Pin<Box<dyn Future<Output = PlatformResult<DaemonHandle>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Spawns a daemon on this platform. Read more
Source§fn signal<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
sig: Signal,
) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn signal<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
sig: Signal,
) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sends a signal to a daemon. Read more
Source§fn status<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
) -> Pin<Box<dyn Future<Output = PlatformResult<DaemonStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn status<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
) -> Pin<Box<dyn Future<Output = PlatformResult<DaemonStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Queries daemon status. Read more
Source§fn attach_tracer<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
) -> Pin<Box<dyn Future<Output = PlatformResult<TracerHandle>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn attach_tracer<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
) -> Pin<Box<dyn Future<Output = PlatformResult<TracerHandle>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Attaches a tracer to a running daemon. Read more
Source§fn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stop<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Gracefully stops a daemon. Read more
Source§fn kill<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn kill<'life0, 'life1, 'async_trait>(
&'life0 self,
handle: &'life1 DaemonHandle,
) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Forcefully kills a daemon. Read more
Auto Trait Implementations§
impl Freeze for SystemdAdapter
impl RefUnwindSafe for SystemdAdapter
impl Send for SystemdAdapter
impl Sync for SystemdAdapter
impl Unpin for SystemdAdapter
impl UnwindSafe for SystemdAdapter
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