Struct launchd::Launchd

source ·
pub struct Launchd { /* private fields */ }
Expand description

Representation of a launchd.plist file. The definition of which can be found here.

Usage:

use launchd::{Launchd, Error, CalendarInterval};
use std::path::Path;

fn example() -> Result<Launchd, Error> {
    Ok(Launchd::new("LABEL", Path::new("./foo/bar.txt"))?
        .with_user_name("Henk")
        .with_program_arguments(vec!["Hello".to_string(), "World!".to_string()])
        .with_start_calendar_intervals(vec![CalendarInterval::default().with_hour(12)?])
        .disabled()
        // etc...
    )
}

let launchd = example();

This will create a launchd representation with the label “LABEL”, running “./foo/bar.txt” with the args “Hello” and “World!”, for the user “Henk”, each day at 12.

NB: The usage is still subject to change.

Implementations§

source§

impl Launchd

source

pub fn new<S: AsRef<str>, P: AsRef<Path>>( label: S, program: P ) -> Result<Self, Error>

source

pub fn with_label<S: AsRef<str>>(self, label: S) -> Self

source

pub fn with_disabled(self, disabled: bool) -> Self

source

pub fn disabled(self) -> Self

source

pub fn with_user_name<S: AsRef<str>>(self, user_name: S) -> Self

source

pub fn with_group_name<S: AsRef<str>>(self, group_name: S) -> Self

source

pub fn with_program<P: AsRef<Path>>(self, program: P) -> Result<Self, Error>

source

pub fn with_bundle_program<S: AsRef<str>>(self, bundle: S) -> Self

source

pub fn with_program_arguments(self, program_arguments: Vec<String>) -> Self

source

pub fn with_run_at_load(self, run_at_load: bool) -> Self

source

pub fn run_at_load(self) -> Self

source

pub fn with_queue_directories(self, queue_directories: Vec<String>) -> Self

source

pub fn with_watch_paths(self, watch_paths: Vec<String>) -> Self

source

pub fn with_start_on_mount(self, start_on_mount: bool) -> Self

source

pub fn start_on_mount(self) -> Self

source

pub fn with_start_interval(self, start_interval: u32) -> Self

source

pub fn with_start_calendar_intervals( self, start_calendar_intervals: Vec<CalendarInterval> ) -> Self

source

pub fn with_abandon_process_group(self, value: bool) -> Self

source

pub fn abandon_process_group(self) -> Self

source

pub fn with_debug(self, value: bool) -> Self

source

pub fn debug(self) -> Self

source

pub fn with_enable_globbing(self, value: bool) -> Self

source

pub fn enable_globbing(self) -> Self

source

pub fn with_enable_transactions(self, value: bool) -> Self

source

pub fn enable_transactions(self) -> Self

source

pub fn with_enable_pressured_exit(self, value: bool) -> Self

source

pub fn enable_pressured_exit(self) -> Self

source

pub fn with_environment_variables(self, env: HashMap<String, String>) -> Self

source

pub fn with_exit_timeout(self, timeout: u32) -> Self

source

pub fn with_init_groups(self, value: bool) -> Self

source

pub fn init_groups(self) -> Self

source

pub fn with_launch_only_once(self, value: bool) -> Self

source

pub fn launch_only_once(self) -> Self

source

pub fn with_limit_load_from_hosts(self, value: Vec<String>) -> Self

source

pub fn with_limit_to_from_hosts(self, value: Vec<String>) -> Self

source

pub fn with_limit_load_to_session_type(self, value: LoadSessionType) -> Self

source

pub fn with_limit_load_to_hardware( self, value: HashMap<String, Vec<String>> ) -> Self

source

pub fn with_limit_load_from_hardware( self, value: HashMap<String, Vec<String>> ) -> Self

source

pub fn with_low_priority_io(self, value: bool) -> Self

source

pub fn low_priority_io(self) -> Self

source

pub fn with_low_priority_background_io(self, value: bool) -> Self

source

pub fn low_priority_background_io(self) -> Self

source

pub fn with_mach_services( self, services: HashMap<String, MachServiceEntry> ) -> Self

source

pub fn with_nice(self, nice: i32) -> Self

source

pub fn with_root_directory<P: AsRef<Path>>(self, path: P) -> Result<Self, Error>

source

pub fn with_standard_error_path<P: AsRef<Path>>( self, path: P ) -> Result<Self, Error>

source

pub fn with_standard_in_path<P: AsRef<Path>>( self, path: P ) -> Result<Self, Error>

source

pub fn with_standard_out_path<P: AsRef<Path>>( self, path: P ) -> Result<Self, Error>

source

pub fn with_throttle_interval(self, value: u32) -> Self

source

pub fn with_timeout(self, timeout: u32) -> Self

source

pub fn with_umask(self, umask: u16) -> Self

source

pub fn with_wait_for_debugger(self, value: bool) -> Self

source

pub fn wait_for_debugger(self) -> Self

source

pub fn with_materialize_dataless_files(self, value: bool) -> Self

source

pub fn materialize_dataless_files(self) -> Self

source

pub fn with_working_directory<P: AsRef<Path>>( self, path: P ) -> Result<Self, Error>

source

pub fn with_inetd_compatibility(self, wait: bool) -> Self

source

pub fn with_keep_alive(self, keep_alive: KeepAliveType) -> Self

source

pub fn with_process_type(self, process_type: ProcessType) -> Self

source

pub fn with_hard_resource_limits(self, limits: ResourceLimits) -> Self

source

pub fn with_soft_resource_limits(self, limits: ResourceLimits) -> Self

source

pub fn with_socket(self, socket: Sockets) -> Self

source

pub fn with_launch_events( self, value: HashMap<String, HashMap<String, HashMap<String, Value>>> ) -> Self

source

pub fn with_session_create(self, value: bool) -> Self

source

pub fn session_create(self) -> Self

source§

impl Launchd

source

pub fn to_writer_xml<W: Write>(&self, writer: W) -> Result<(), Error>

source

pub fn to_file_xml<P: AsRef<Path>>(&self, file: P) -> Result<(), Error>

source

pub fn to_writer_binary<W: Write>(&self, writer: W) -> Result<(), Error>

source

pub fn to_file_binary<P: AsRef<Path>>(&self, file: P) -> Result<(), Error>

source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>

source

pub fn from_file<P: AsRef<Path>>(file: P) -> Result<Self, Error>

source

pub fn from_reader<R: Read + Seek>(reader: R) -> Result<Self, Error>

source

pub fn from_reader_xml<R: Read + Seek>(reader: R) -> Result<Self, Error>

Trait Implementations§

source§

impl Debug for Launchd

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Launchd

source§

fn default() -> Launchd

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Launchd

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq<Launchd> for Launchd

source§

fn eq(&self, other: &Launchd) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Launchd

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Launchd

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,