StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | use anyhow::{anyhow, Result}; |
| 2 | use std::borrow::Cow; |
| 3 | pub mod root_view; |
| 4 | |
| 5 | extern crate strato_ui; |
| 6 | use rust_embed::RustEmbed; |
| 7 | use strato_ui::{platform, AssetProvider}; |
| 8 | |
| 9 | #[derive(Clone, Copy, RustEmbed)] |
| 10 | #[folder = "examples/assets"] |
| 11 | pub struct Assets; |
| 12 | |
| 13 | pub static ASSETS: Assets = Assets; |
| 14 | |
| 15 | impl 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 | |
| 23 | fn main() -> Result<()> { |
| 24 | let app_builder = |
| 25 | platform::AppBuilder::new(platform::AppCallbacks::default(), Box::new(ASSETS), None); |
| 26 | let _ = app_builder.run(move |ctx| { |
| 27 | ctx.add_window( |
| 28 | strato_ui::AddWindowOptions::default(), |
| 29 | root_view::RootView::new, |
| 30 | ); |
| 31 | }); |
| 32 | |
| 33 | Ok(()) |
| 34 | } |
| 35 |