Skip to main content

ServiceDefinition

Struct ServiceDefinition 

Source
pub struct ServiceDefinition { /* private fields */ }
Expand description

One platform’s definition of the registration, as text.

Producing this is pure: no cfg, no privileges, no filesystem. That is what lets every leg of the CI matrix assert every platform’s definition, instead of each leg asserting only its own and the other two being reviewed by reading.

Implementations§

Source§

impl ServiceDefinition

Source

pub const fn kind(&self) -> DefinitionKind

Which platform this is for.

Source

pub fn text(&self) -> &str

The definition itself.

Source

pub fn install_path(&self) -> Option<&Path>

Where the platform expects the file, when the platform reads a file.

None for DefinitionKind::WindowsService, whose “definition” is a set of arguments to CreateServiceW, and for a Task Scheduler document, which is handed to schtasks from a temporary file and is not stored where it was written.

Source

pub fn for_host(plan: &InstallPlan) -> Result<Self, ServiceError>

The definition this host’s own service manager would be given.

The value-level twin of host_definition_kind. Rendering needs no privileges and no service manager, so anything that wants to see what an install would register — f3’s service install --dry-run, a support bundle, RecordingControls — can have it without registering anything.

§Errors

ServiceError::Control when a Windows logon-triggered registration is asked for and the session reports no account to register it for.

Source

pub fn windows_service(plan: &InstallPlan) -> Self

The Windows service parameters, as a canonical descriptor.

Source

pub fn windows_scheduled_task( plan: &InstallPlan, principal: &TaskPrincipal, ) -> Self

A Task Scheduler document for --start-at login.

Source

pub fn launchd(plan: &InstallPlan, home: Option<&Path>) -> Self

A launchd property list.

home is only consulted for --start-at login, where the file belongs in the operator’s own ~/Library/LaunchAgents.

Source

pub fn from_text(kind: DefinitionKind, text: impl Into<String>) -> Self

Wraps text this module did not render.

Two callers need it and both matter. A test builds a deliberately widened definition and watches review_least_privilege reject it — without which the review would be a function nobody had ever seen fail. And service status can review the definition actually on disk, which on Linux and macOS an operator is free to edit after installation.

Source

pub fn systemd(plan: &InstallPlan, home: Option<&Path>) -> Self

A systemd unit.

home is only consulted for --start-at login, where the unit belongs in the operator’s own ~/.config/systemd/user.

Trait Implementations§

Source§

impl Clone for ServiceDefinition

Source§

fn clone(&self) -> ServiceDefinition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ServiceDefinition

Source§

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

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

impl Eq for ServiceDefinition

Source§

impl PartialEq for ServiceDefinition

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ServiceDefinition

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more