pub struct Runtime { /* private fields */ }
Expand description
A Runtime handles the application event loop and connects to the various device drivers.
§Examples
use kioto::runtime;
fn main() {
let mut runtime = runtime::Runtime::new();
runtime.run_with(|runtime| {
runtime.shutdown();
Ok(())
});
}
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new runtime with the default configuration.
§Examples
use kioto::runtime;
fn main() {
let runtime = runtime::Runtime::new();
}
Sourcepub fn run_with<F>(&mut self, callback: F) -> Result<(), Error>
pub fn run_with<F>(&mut self, callback: F) -> Result<(), Error>
Run the runtime loop with the given callback which is called once per tick until shutdown.
§Examples
use kioto::runtime;
fn main() {
let mut runtime = runtime::Runtime::new();
runtime.run_with(|runtime| {
runtime.shutdown();
Ok(())
});
}
Examples found in repository?
examples/snake.rs (lines 149-154)
141fn main() {
142 let state_cell = RefCell::new(State::new());
143 let mut runtime = Builder::new()
144 .title("Snake")
145 .enable_video()
146 .build()
147 .unwrap();
148
149 runtime.run_with(|_runtime| {
150 let mut state = state_cell.borrow_mut();
151 state.tick();
152
153 Ok(())
154 }).unwrap();
155}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Runtime
impl RefUnwindSafe for Runtime
impl Send for Runtime
impl Sync for Runtime
impl Unpin for Runtime
impl UnwindSafe for Runtime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more