Doorbell

Struct Doorbell 

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

A doorbell for cross-process wakeup.

Uses a Unix domain socketpair (SOCK_DGRAM) for bidirectional signaling. Wrapped in AsyncFd for async readiness notification via epoll/kqueue.

Implementations§

Source§

impl Doorbell

Source

pub fn create_pair() -> Result<(Self, DoorbellHandle)>

Create a socketpair and return (host_doorbell, guest_handle).

The guest_handle should be passed to the plugin (e.g., via command line). The host keeps the Doorbell.

Source

pub fn from_handle(handle: DoorbellHandle) -> Result<Self>

Create a Doorbell from an opaque handle (guest/plugin side).

This is the cross-platform way to reconstruct a Doorbell in a spawned process. Consumes the handle, taking ownership of the underlying file descriptor.

Source

pub fn from_raw_fd(fd: RawFd) -> Result<Self>

Create a Doorbell from a raw file descriptor (plugin side).

Prefer Self::from_handle for cross-platform code.

§Safety

The fd must be a valid, open file descriptor from a socketpair.

Source

pub async fn signal(&self) -> SignalResult

Signal the other side.

Sends a 1-byte datagram. If the socket buffer is full (EAGAIN), the signal is dropped (the other side is already signaled).

Returns SignalResult::PeerDead if the peer has disconnected (EPIPE, ECONNRESET, ENOTCONN). This is logged once per doorbell to avoid spam.

Source

pub fn is_peer_dead(&self) -> bool

Check if the peer appears to be dead (signal has failed).

Source

pub async fn wait(&self) -> Result<()>

Wait for a signal from the other side.

Source

pub fn drain(&self)

Drain any pending signals without blocking.

Source

pub async fn accept(&self) -> Result<()>

Accept an incoming connection (no-op on Unix).

On Unix, socketpairs are already connected when created, so this is a no-op. On Windows, named pipe servers must call this to accept the client connection.

Source

pub fn pending_bytes(&self) -> usize

Get the number of bytes pending in the socket buffer (for diagnostics).

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