#protobuf #prost #polar

polar-prost

Protobuf bindings to interact with Polar watches

1 unstable release

0.1.0 Nov 15, 2019

#4 in #polar

MIT license

135KB
3.5K SLoC

Polar Prost

polar-prost is a library with pre-generated protobuf Rust bindings to interact with Polar watches. It uses Prost to generate the bindings.

Why pre-generated? Because it's easier to use and avoids autocompletion bugs like this one.

Warning: This library has barely been tested and the definitions might not match the ones on the watch. Use at your own risk.

Usage

cargo.toml

[dependencies]
polar-prost = "0.1.0"

your_code.rs

extern crate polar_prost;

use polar_prost::{encode, types, Message};

fn main() {
    let text = "Hello, World!";

    // Manually create a polar line text object
    let line = types::PbOneLineText {
        text: text.to_string()
    };

    // Encode it into a buffer
    let buffer = encode(line).unwrap();

    // Decode it again
    let new_line = types::PbOneLineText::decode(buffer).unwrap();

    // Make sure the text didn't change
    assert_eq!(text, new_line.text);
}

Thanks

@cmaion for writting a Ruby tool to interact with Polar watches. The proto files on this library are based on his.

Dependencies

~5–11MB
~140K SLoC