Add timers for Rust event loops

Change-Id: I2fd9077836fa4d6cc5d525dd369c993099528af1
Signed-off-by: Adam Snaider <adsnaider@gmail.com>
diff --git a/aos/events/event_loop_runtime.cc b/aos/events/event_loop_runtime.cc
index 727d806..e3d73c1 100644
--- a/aos/events/event_loop_runtime.cc
+++ b/aos/events/event_loop_runtime.cc
@@ -8,4 +8,22 @@
 OnRunForRust::~OnRunForRust() { --runtime_->child_count_; }
 bool OnRunForRust::is_running() const { return runtime_->is_running(); }
 
+std::unique_ptr<TimerForRust> TimerForRust::Make(EventLoopRuntime *runtime) {
+  auto handler = std::unique_ptr<TimerForRust>(new TimerForRust());
+  TimerForRust *inner = handler.get();
+  handler->timer_ = runtime->event_loop()->AddTimer([inner, runtime] {
+    inner->expired_ = true;
+    runtime->DoPoll();
+  });
+  return handler;
+}
+
+bool TimerForRust::Poll() {
+  if (expired_) {
+    // Reset it for next poll.
+    expired_ = false;
+    return true;
+  }
+  return false;
+}
 }  // namespace aos