Mercurial > templog
annotate rust/src/main.rs @ 590:dccd8504aa38 rust
it runs
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 21 Dec 2016 21:40:32 +0800 |
parents | f2508125adf1 |
children | 4a944663fa8d |
rev | line source |
---|---|
588
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
1 extern crate tokio_core; |
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
2 extern crate futures; |
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
3 |
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
4 use tokio_core::reactor::Core; |
590 | 5 use futures::Stream; |
589
f2508125adf1
Try using traits for periodic stream
Matt Johnston <matt@ucc.asn.au>
parents:
588
diff
changeset
|
6 |
590 | 7 mod sensor; |
587 | 8 |
9 fn main() { | |
10 println!("Wort Templog"); | |
588
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
11 |
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
12 let mut core = Core::new().unwrap(); |
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
13 let handle = core.handle(); |
587 | 14 |
590 | 15 let s = sensor::Sensor::run(&handle); |
587 | 16 |
588
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
17 let h = s.for_each(|r| { |
590 | 18 println!("readings {:?}", r); |
588
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
19 Ok(()) |
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
20 }); |
587 | 21 |
588
038734052b20
fiddling with futures-rs instead
Matt Johnston <matt@ucc.asn.au>
parents:
587
diff
changeset
|
22 core.run(h); |
587 | 23 } |
24 |