Expand description
§WebExtension Native Messaging
WebExtension native messaging library for Rust.
§Reading
In your web extension:
const port = browser.runtime.connectNative('native executable');
port.postMessage('Hey, there!');
Then in your native executable:
use webextension_native_messaging::read_message;
let message = read_message::<String>().unwrap();
println!("{}", message);
§Writing
In your web extension:
const port = browser.runtime.connectNative('native executable');
port.onMessage.addListener((message) => {
console.log(message);
});
Then in your native executable:
use webextension_native_messaging::write_message;
let message = "Hey, there!".to_string();
write_message(&message).unwrap();
See the native messaging documentation for precise instructions on how to send and receive messages.
Enums§
- Messaging
Error - All possible errors that can happen with reading or writing messages.
Functions§
- read_
message - Attempts to read a message from the program’s stdin in the native messaging format.
- write_
message - Attempts to write a message to the program’s stdout in the native messaging format.