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
impl Plugin
Sourcepub async fn spawn(spec: PluginSpec) -> Result<Self, PluginError>
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.
Sourcepub async fn dial(&mut self) -> Result<&H2Channel, PluginError>
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).
Sourcepub fn handshake(&self) -> &HandshakeLine
pub fn handshake(&self) -> &HandshakeLine
The negotiated handshake (protocol version, transport, address, cert).
Sourcepub fn parent_identity(&self) -> &ParentIdentity
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.
Sourcepub fn channel(&self) -> Option<&H2Channel>
pub fn channel(&self) -> Option<&H2Channel>
The dialed gRPC channel, if dial() has been called.
Sourcepub fn crash_lines(&self) -> Vec<String>
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.
Sourcepub fn crash_summary(&self) -> Option<ProviderCrash>
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.
Sourcepub fn exit_signal(&mut self) -> Option<i32>
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§
Auto Trait Implementations§
impl !RefUnwindSafe for Plugin
impl !UnwindSafe for Plugin
impl Freeze for Plugin
impl Send for Plugin
impl Sync for Plugin
impl Unpin for Plugin
impl UnsafeUnpin for Plugin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request