Skip to content
This repository was archived by the owner on Jan 15, 2022. It is now read-only.

Commit d934ac9

Browse files
author
Kit Cambridge
committed
Add a Web Ext native messaging bridge.
The bridge communicates with the Web Extension via length-prefixed JSON messages over std{in, out}. It manages a single `Toodle` store, in a fixed location, and translates the messages into method calls. The API still needs some work: in particular, we always read before and after writing; we can't set labels yet, because we need to fetch their IDs to set them on items, and removing items and labels isn't supported yet. Error handling and reporting could also be more robust. For the bridge to work, the native manifest must live in a specific location, and include a `path` key that points to the bridge binary. Running `./install-native-manifest.js` automatically sets the path and copies the manifest to the correct location on macOS. Windows and Linux use different locations, but the install script doesn't handle them yet. This only needs to be done once.
1 parent 68f34d6 commit d934ac9

File tree

9 files changed

+536
-19
lines changed

9 files changed

+536
-19
lines changed

rust/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,16 @@ use libc::{
3535
time_t,
3636
};
3737

38-
use time::{
39-
Timespec,
40-
};
41-
4238
use mentat::{
4339
IntoResult,
4440
QueryExecutionResult,
4541
TypedValue,
46-
Uuid,
4742
Variable,
4843
};
4944

45+
pub use time::Timespec;
46+
pub use mentat::Uuid;
47+
5048
pub mod labels;
5149
pub mod items;
5250
pub mod errors;
@@ -85,7 +83,7 @@ pub struct Toodle {
8583
}
8684

8785
impl Toodle {
88-
fn new(uri: String) -> Result<Toodle, errors::Error> {
86+
pub fn new(uri: String) -> Result<Toodle, errors::Error> {
8987
let store_result = Store::new_store(uri)?;
9088
let mut toodle = Toodle {
9189
connection: store_result,

toodlext/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/target/
2+
**/*.rs.bk
3+
Cargo.lock
4+
*.sqlite

toodlext/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "toodlext"
3+
version = "0.1.0"
4+
authors = ["Kit Cambridge <kit@mozilla.com>"]
5+
description = "Web Extension native messaging bridge for Toodle"
6+
7+
[[bin]]
8+
path = "src/main.rs"
9+
name = "toodlext"
10+
11+
[dependencies]
12+
byteorder = "1.1.0"
13+
serde = "1.0.21"
14+
serde_derive = "1.0.21"
15+
serde_json = "1.0.6"
16+
toodle = { path = "../rust", version = "0.1.0" }

0 commit comments

Comments
 (0)