Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-ui-renderer/examples/frame-capture-test/main.rs
1use anyhow::{anyhow, Result};
2use std::borrow::Cow;
3pub mod root_view;
4 
5extern crate strato_ui;
6use rust_embed::RustEmbed;
7use strato_ui::{platform, AssetProvider};
8 
9#[derive(Clone, Copy, RustEmbed)]
10#[folder = "examples/assets"]
11pub struct Assets;
12 
13pub static ASSETS: Assets = Assets;
14 
15impl AssetProvider for Assets {
16 fn get(&self, path: &str) -> Result<Cow<'_, [u8]>> {
17 <Assets as RustEmbed>::get(path)
18 .map(|f| f.data)
19 .ok_or_else(|| anyhow!("no asset exists at path {}", path))
20 }
21}
22 
23fn main() -> Result<()> {
24 env_logger::init();
25 
26 let app_builder =
27 platform::AppBuilder::new(platform::AppCallbacks::default(), Box::new(ASSETS), None);
28 let _ = app_builder.run(move |ctx| {
29 ctx.add_window(
30 strato_ui::AddWindowOptions::default(),
31 root_view::RootView::new,
32 );
33 });
34 
35 Ok(())
36}
37