Struct ServiceHandle

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

Represents a handle to a Windows service.

Implementations§

Source§

impl ServiceHandle

Source

pub fn new(handle: SC_HANDLE) -> Self

Creates a new ServiceHandle.

Source

pub fn state(&self) -> Result<ServiceState, QueryServiceError>

Returns the current state of this ServiceHandle.

§Errors

This function will return an error if it can’t retrieve the service status.

Source

pub fn update_config( &self, options: ServiceConfig, ) -> Result<(), UpdateServiceError>

Updates the configuration of the service.

§Errors

This function will return an error if it can’t update the service configuration.

Source

pub fn get_start_type(&self) -> Result<ServiceStartType, QueryServiceError>

Returns the get start type of this ServiceHandle.

§Errors

This function will return an error if it can’t get the start type.

Source

pub fn set_start_type( &self, start_type: ServiceStartType, ) -> Result<(), UpdateServiceError>

Sets the start type of the service.

§Errors

This function will return an error if it can’t set the start type.

Source

pub fn delete(&self) -> Result<(), DeleteServiceError>

Source

pub fn start_blocking(&self) -> Result<(), ControlServiceError>

Starts the service and blocks until it is running.

§Errors

This function will return an error if it can’t start the service.

Source

pub fn stop_blocking(&self) -> Result<(), ControlServiceError>

Stops the service and blocks until it is stopped.

§Errors

This function will return an error if it can’t stop the service.

Source

pub fn pause_blocking(&self) -> Result<(), ControlServiceError>

Pauses the service and blocks until it is paused.

§Errors

This function will return an error if it can’t pause the service.

Source

pub fn start(&self) -> Result<(), ControlServiceError>

Starts the service.

§Errors

This function will return an error if it can’t start the service.

Source

pub fn stop(&self) -> Result<(), ControlServiceError>

Stops the service.

§Errors

This function will return an error if it can’t stop the service.

Source

pub fn pause(&self) -> Result<(), ControlServiceError>

Pauses the service.

§Errors

This function will return an error if it can’t pause the service.

Trait Implementations§

Source§

impl Debug for ServiceHandle

Source§

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

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

impl Default for ServiceHandle

Source§

fn default() -> ServiceHandle

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

impl Display for ServiceHandle

Source§

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

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

impl Drop for ServiceHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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 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.