1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! `xrl` is a Tokio based library to build clients for the Xi editor. The
//! challenge with Xi RPC is that endpoints are both client (sending
//! requests/notifications) and server (handling incoming
//! requests/notifications).
//!
//!
//! ```rust
//!
//! #![allow(unused_variables)]
//! extern crate futures;
//! extern crate tokio_core;
//! extern crate xrl;
//!
//! use futures::{future, Future, Stream};
//! use tokio_core::reactor::Core;
//! use xrl::*;
//!
//!
//! // Type that represent our client
//! struct MyFrontend {
//! client: Client,
//! }
//!
//! // Implement how our client handles notifications & requests from the core.
//! impl Frontend for MyFrontend {
//! fn update(&mut self, update: Update) -> ServerResult<()> {
//! println!("received `update` from Xi core:\n{:?}", update);
//! // note that here, we could send requests/notifications
//! // to the core here with `self.client`
//! Box::new(future::ok(()))
//! }
//! fn scroll_to(&mut self, scroll_to: ScrollTo) -> ServerResult<()> {
//! println!("received `scroll_to` from Xi core:\n{:?}", scroll_to);
//! Box::new(future::ok(()))
//! }
//! fn def_style(&mut self, style: Style) -> ServerResult<()> {
//! println!("received `set_style` from Xi core:\n{:?}", style);
//! Box::new(future::ok(()))
//! }
//! }
//!
//! struct MyFrontendBuilder;
//!
//! impl FrontendBuilder<MyFrontend> for MyFrontendBuilder {
//! fn build(self, client: Client) -> MyFrontend {
//! MyFrontend { client: client }
//! }
//! }
//!
//! fn main() {
//! let mut core = Core::new().unwrap();
//! let handle = core.handle();
//!
//! // spawn Xi core
//! let (mut client, core_stderr) = spawn("xi-core", MyFrontendBuilder {},
//! &handle);
//!
//! // start logging Xi core's stderr
//! let log_core_errors = core_stderr
//! .for_each(|msg| {
//! println!("xi-core stderr: {}", msg);
//! Ok(())
//! })
//! .map_err(|_| ());
//! core.handle().spawn(log_core_errors);
//!
//! // Send a request to open a new view, and print the result
//! let open_new_view = client
//! .new_view(None)
//! .map(|view_name| println!("opened new view: {}", view_name));
//! core.run(open_new_view).unwrap();
//! }
//! ```
extern crate bytes;
extern crate futures;
extern crate log;
extern crate serde;
extern crate serde_derive;
extern crate serde_json;
extern crate tokio_core;
extern crate tokio_io;
extern crate tokio_process;
extern crate syntect;
pub use LineCache;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;