pub struct NativePlugin { /* private fields */ }Expand description
A loaded native plugin that can be called via FFI.
The plugin is automatically shut down when dropped.
Implementations§
Source§impl NativePlugin
impl NativePlugin
Sourcepub fn call_typed<Req, Res>(
&self,
type_tag: &str,
request: &Req,
) -> ConsumerResult<Res>where
Req: Serialize,
Res: DeserializeOwned,
pub fn call_typed<Req, Res>(
&self,
type_tag: &str,
request: &Req,
) -> ConsumerResult<Res>where
Req: Serialize,
Res: DeserializeOwned,
Make a typed call to the plugin with automatic serialization.
§Arguments
type_tag- Message type identifierrequest- Request value to serialize to JSON
§Returns
The deserialized response, or an error.
§Example
ⓘ
#[derive(Serialize)]
struct EchoRequest { message: String }
#[derive(Deserialize)]
struct EchoResponse { message: String, length: usize }
let response: EchoResponse = plugin.call_typed("echo", &EchoRequest {
message: "Hello".to_string(),
})?;Sourcepub fn state(&self) -> LifecycleState
pub fn state(&self) -> LifecycleState
Get the current lifecycle state of the plugin.
Sourcepub fn rejected_request_count(&self) -> u64
pub fn rejected_request_count(&self) -> u64
Get the number of requests rejected due to concurrency limits.
Sourcepub fn has_binary_transport(&self) -> bool
pub fn has_binary_transport(&self) -> bool
Check if binary transport is available.
Sourcepub fn set_log_level(&self, level: LogLevel)
pub fn set_log_level(&self, level: LogLevel)
Set the log level for the plugin.
Sourcepub fn shutdown(&self) -> ConsumerResult<()>
pub fn shutdown(&self) -> ConsumerResult<()>
Shutdown the plugin gracefully.
This is called automatically when the plugin is dropped, but can be called explicitly to handle shutdown errors.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for NativePlugin
impl RefUnwindSafe for NativePlugin
impl Unpin for NativePlugin
impl UnsafeUnpin for NativePlugin
impl UnwindSafe for NativePlugin
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
Mutably borrows from an owned value. Read more