[][src]Struct spirit_daemonize::UserDaemon

#[non_exhaustive]pub struct UserDaemon {
    pub pid_file: Option<PathBuf>,
    pub workdir: Option<PathBuf>,
    pub daemonize: bool,
}

A stripped-down version of Daemon without the user-switching options.

Sometimes, the daemon either needs to keep the root privileges or is started with the appropriate user right away, therefore the user should not be able to configure the user and group options.

This configuration fragment serves the role. Convert it to Daemon first, by into_daemon (or using the Into trait).

Examples

use spirit_daemonize::{Daemon, UserDaemon};

// No way to access the `pid_file` and others inside this thing and can't call `.daemonize()`.
let user_daemon = UserDaemon::default();

let daemon: Daemon = user_daemon.into();
assert!(daemon.pid_file.is_none());
assert_eq!(daemon, Daemon::default());

Fields (Non-exhaustive)

Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
pid_file: Option<PathBuf>

Where to store a PID file.

If not set, no PID file is created.

workdir: Option<PathBuf>

Switch to this working directory at startup.

If not set, working directory is not switched.

daemonize: bool

Enable the daemonization.

Even if this is false, some activity (setting PID file, etc) is still done, but it doesn't go to background.

Implementations

impl UserDaemon[src]

pub fn into_daemon(self) -> Daemon[src]

Converts to full-featured Daemon.

All the useful functionality is on Daemon, therefore to use it, convert it first.

It can be also converted using the usual From/Into traits.

Trait Implementations

impl Clone for UserDaemon[src]

impl Debug for UserDaemon[src]

impl Default for UserDaemon[src]

impl<'de> Deserialize<'de> for UserDaemon[src]

impl Eq for UserDaemon[src]

impl From<UserDaemon> for Daemon[src]

impl PartialEq<UserDaemon> for UserDaemon[src]

impl Serialize for UserDaemon[src]

impl StructDoc for UserDaemon[src]

impl StructuralEq for UserDaemon[src]

impl StructuralPartialEq for UserDaemon[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoResult<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.