Skip to content

Commit 5a19b34

Browse files
authored
Merge pull request rust-lang#1 from fabiand/smallerFixes
Fix some smaller compilation issues with rust-1.22
2 parents b885b26 + 83e7f5a commit 5a19b34

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# rust-varlink
22
WIP
33

4+
## varlink tool installaiton
5+
6+
```bash
7+
$ sudo dnf copr enable "@varlink/varlink"
8+
$ sudo dnf install fedora-varlink
9+
$ sudo setenforce 0 # needed until systemd is able to create sockets in /run
10+
$ sudo systemctl enable --now org.varlink.resolver.socket
11+
$ varlink help
12+
```
13+
414
## varlink file validator
515
```
616
$ cargo run --example validate examples/io_systemd_network/io.systemd.network.varlink

examples/server.rs

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ fn main() {
115115

116116
let state = Arc::new(RwLock::new(0));
117117

118+
println!("Listening on {}", addr);
119+
118120
// We provide a way to *instantiate* the service for each new
119121
// connection; here, we just immediately return a new instance.
120122
server.serve(move || {

src/server.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::borrow::Cow;
88
use bytes::BytesMut;
99
use bytes::BufMut;
1010

11-
use futures::{future, Future, BoxFuture};
11+
use futures::{future, Future};
1212

1313
use tokio_proto::pipeline::ServerProto;
1414
use tokio_service::Service;
@@ -40,7 +40,7 @@ pub struct Error {
4040
}
4141

4242
impl From<serde_json::Error> for Error {
43-
fn from(e: serde_json::Error) -> Self {
43+
fn from(_e: serde_json::Error) -> Self {
4444
Error {
4545
error: "UnknownError".into(),
4646
..Default::default()
@@ -177,19 +177,19 @@ impl Service for VarlinkService {
177177
type Error = io::Error;
178178

179179
// The future for computing the response; box it for simplicity.
180-
type Future = BoxFuture<Self::Response, Self::Error>;
180+
type Future = Box<Future<Item=Self::Response, Error=Self::Error> + Send>;
181181

182182
// Produce a future for computing a response from a request.
183183
fn call(&self, req: Self::Request) -> Self::Future {
184184

185185
println!("Request: {}", serde_json::to_string(&req).unwrap());
186186
let n: usize = match req.method.rfind('.') {
187187
None => {
188-
return future::ok(Response::Err(Error {
188+
return Box::new(future::ok(Response::Err(Error {
189189
error: "InterfaceNotFound".into(),
190190
parameters: Some(json!({"interface": req.method})),
191191
..Default::default()
192-
})).boxed()
192+
})))
193193
}
194194
Some(x) => x,
195195
};
@@ -199,24 +199,24 @@ impl Service for VarlinkService {
199199
match iface.as_ref() {
200200
"org.varlink.service" => {
201201
match self::Interface::call(self, req) {
202-
Ok(val) => future::ok(Response::Ok(Reply { parameters: Some(val) })).boxed(),
203-
Err(e) => future::ok(Response::Err(e)).boxed(),
202+
Ok(val) => Box::new(future::ok(Response::Ok(Reply { parameters: Some(val) }))),
203+
Err(e) => Box::new(future::ok(Response::Err(e)))
204204
}
205205
}
206206
key => {
207207
if self.ifaces.contains_key(key) {
208208
match self.ifaces[key].call(req) {
209209
Ok(val) => {
210-
future::ok(Response::Ok(Reply { parameters: Some(val) })).boxed()
210+
Box::new(future::ok(Response::Ok(Reply { parameters: Some(val) })))
211211
}
212-
Err(e) => future::ok(Response::Err(e)).boxed(),
212+
Err(e) => Box::new(future::ok(Response::Err(e))),
213213
}
214214
} else {
215-
future::ok(Response::Err(Error {
215+
Box::new(future::ok(Response::Err(Error {
216216
error: "InterfaceNotFound".into(),
217217
parameters: Some(json!({"interface": key})),
218218
..Default::default()
219-
})).boxed()
219+
})))
220220
}
221221
}
222222

0 commit comments

Comments
 (0)