Struct ListenInit

Source
pub struct ListenInit<F> {
    pub listen: ListenFd,
    pub file: Option<F>,
    pub target: c_int,
    /* private fields */
}
Expand description

A ListenFd enriched with a relevant file descriptor for passing to a child process.

This either captures one of the file descriptors passed, or initialized a new owning file descriptor, generally a file. It also computes the target file descriptor number. That is, if the file was captured by finding its name in the LISTN_FDNAMES array then it is computed and in-bounds of the passed array. If the file was not captured, it is added to the listen information and its new hypothetical descriptor is stored in target.

Fields§

§listen: ListenFd

The originally, potentially modified, passed ListenFd.

§file: Option<F>

Owns the file if it had to be constructed due to not being found.

§target: c_int

The file descriptor the file would have in childs (or the next restart if registered).

See struct description.

Implementations§

Source§

impl<F> ListenInit<F>

Source

pub fn named_or_try_create<R>( this: Option<ListenFd>, fd_name: &str, with: impl FnOnce() -> Result<F, R>, ) -> Result<Self, R>

Derive a new ListenFd setup, finds or adds a file descriptor.

Source

pub fn maybe_notify(&self, notify: NotifyFd, fd_name: &str) -> Result<(), Error>
where F: AsRawFd,

Available on crate feature std only.

Notify systemd, if the file descriptor was not present.

Source

pub unsafe fn wrap_proc(&self, proc: &mut Command)
where F: AsRawFd,

Available on crate feature std only.

Modify a command such that it copies the file descriptors at the appropriate location.

§Safety

This function is unsafe, since the caller must prove that copying the file descriptors is okay.

Auto Trait Implementations§

§

impl<F> Freeze for ListenInit<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for ListenInit<F>
where F: RefUnwindSafe,

§

impl<F> Send for ListenInit<F>
where F: Send,

§

impl<F> Sync for ListenInit<F>
where F: Sync,

§

impl<F> Unpin for ListenInit<F>
where F: Unpin,

§

impl<F> UnwindSafe for ListenInit<F>
where F: UnwindSafe,

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.