Pid

Struct Pid 

Source
pub struct Pid {
    pub process_id: u32,
    pub file_path: String,
    /* private fields */
}
Expand description

Represents a PID (Process ID) file.

The Pid structure provides functionality for creating, reading, and managing a PID file, which typically contains the process ID of a running program.

Fields§

§process_id: u32

process_id stored inside the file.

§file_path: String

path of the file.

Implementations§

Source§

impl Pid

Source

pub fn new<T: Display>(path: T, name: T) -> Result<Self>

Creates a new Pid instance with the specified file path and name.

§Arguments
  • path - The path where the PID file will be stored.
  • name - The name of the PID file (without the extension).
§Errors

Returns an std::io::Error if the file cannot be opened, locked, or written.

§Examples
use filelock_rs::pid::Pid;

let pid = Pid::new("/var/run", "my_program").unwrap();

Trait Implementations§

Source§

impl Drop for Pid

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Pid

§

impl RefUnwindSafe for Pid

§

impl Send for Pid

§

impl Sync for Pid

§

impl Unpin for Pid

§

impl UnwindSafe for Pid

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