Skip to main content

Plugin

Struct Plugin 

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

A live provider plugin. Holds the subprocess, the parsed handshake, the ephemeral parent identity used for mTLS, and (once dialed) the tonic gRPC Channel ready for typed RPC.

Implementations§

Source§

impl Plugin

Source

pub async fn spawn(spec: PluginSpec) -> Result<Self, PluginError>

Spawn a provider plugin, complete the handshake, return a live Plugin.

§Errors

Returns PluginError if the binary is missing, the magic cookie is rejected, the handshake line is malformed, or the protocol negotiation fails.

Source

pub async fn dial(&mut self) -> Result<&H2Channel, PluginError>

Dial the gRPC channel to the provider over mTLS. Supports both tcp and unix network transports per the go-plugin handshake.

Builds a rustls ClientConfig:

  • parent cert + key as client identity (mTLS client auth)
  • custom verifier that trusts only the provider’s specific cert from the handshake line (not a CA chain — both ends are self-signed)

Wraps the underlying stream (UnixStream or TcpStream) in a tokio_rustls TlsStream, then drives a hyper HTTP/2 connection over it directly (see H2Channel for why not tonic Channel).

Source

pub fn handshake(&self) -> &HandshakeLine

The negotiated handshake (protocol version, transport, address, cert).

Source

pub fn parent_identity(&self) -> &ParentIdentity

The ephemeral parent identity (cert + key) generated for this spawn. Exposed for tonic-rustls mTLS layering in M0.x.

Source

pub fn channel(&self) -> Option<&H2Channel>

The dialed gRPC channel, if dial() has been called.

Source

pub fn crash_lines(&self) -> Vec<String>

Snapshot of the crash-signal lines captured from the provider’s stderr/stdout (panic / SIGSEGV / fatal-error backtrace). Empty while the provider is healthy. Read at every RPC failure site so a subprocess crash surfaces as a precise typed error.

Source

pub fn crash_summary(&self) -> Option<ProviderCrash>

A typed ProviderCrash summary, Some iff any crash-signal line was captured. Best-effort: the backtrace may still be draining when an RPC error returns (the panic + the h2 broken-pipe arrive on separate tasks), so this returns whatever has been seen so far. signal is read via the non-blocking Plugin::exit_signal (&mut) confirmation when available; from behind a shared borrow it stays None and the captured panic lines carry the meaning.

Source

pub fn exit_signal(&mut self) -> Option<i32>

Best-effort: the unix signal the subprocess died from, if it has already exited and not yet been reaped by Drop. 11 = SIGSEGV. Non-blocking (try_wait), so None while the process is still alive, on a non-unix target, or if the exit carried no signal. A numeric confirmation of the stderr-captured panic — never load-bearing; the captured panic lines are the meaning.

Trait Implementations§

Source§

impl Drop for Plugin

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> 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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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