pub fn send_message<W: Write, T: Serialize>(
    output: W,
    value: &T
) -> Result<(), Error>
Expand description

Writes an output to a stream, encoded according to Chrome’s documentation on native messaging. (https://developer.chrome.com/extensions/nativeMessaging) Takes a custom value which implements serde::Serialize.

Example

use chrome_native_messaging::send_message;
use std::io;
use serde::Serialize;
use serde_json::json;

#[derive(Serialize)]
struct BasicMessage<'a> {
    payload: &'a str
}

send_message(io::stdout(), &BasicMessage { payload: "Hello, World! "})
    .expect("failed to send to stdout");