diff --git a/Cargo.toml b/Cargo.toml index dcc8fb7..e574f8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ repository = "https://github.com/concoct-rs/concoct" full = ["tracing"] [dependencies] -futures = "0.3.30" -rustc-hash = "1.1.0" +futures = { version = "0.3.30", default-features = false } +hashbrown = { version = "0.14.3" } tracing = { version = "0.1.40", optional = true } [package.metadata.docs.rs] diff --git a/README.md b/README.md index 7f94bde..f81d07a 100644 --- a/README.md +++ b/README.md @@ -15,50 +15,26 @@ -
- Examples -
-
-Concoct is a framework for user-interfaces in Rust. - -This crate provides a virtual DOM and state management system for any backend. -Concoct uses static typing to describe your UI at compile-time to create an efficient -tree without allocations. +Concoct is a reactive runtime for embedded systems. ```rust -use concoct::{Scope, View}; -use concoct_web::html; - -#[derive(Default)] -struct Counter { - count: i32, -} +use concoct::{ + task::{self, Task}, + System, +}; -impl View for Counter { - fn body(&mut self, _cx: &Scope) -> impl View { - ( - format!("High five count: {}", self.count), - html::button("Up high!").on_click(|_cx, state: &mut Self, _event| state.count += 1), - html::button("Down low!").on_click(|_cx, state: &mut Self, _event| state.count -= 1), - ) - } +fn app(_count: &mut i32) -> impl Task { + task::from_fn(|_| dbg!("Hello World!")) } fn main() { - concoct_web::launch(Counter::default()) + let mut system = System::new(0, app); + system.build(); + system.rebuild(); } ``` -## Installation -The easiest way to get started is using the `full` feature flag. - -``` -cargo add concoct --features full -``` - -To see a list of the available features flags that can be enabled, check our [docs](https://docs.rs/concoct/latest/concoct/#feature-flags). - ## Inspiration -This crate is inspired by [xilem](https://github.com/linebender/xilem), React, and SwiftUI. +This crate is inspired by [xilem](https://github.com/linebender/xilem), [Drake](https://drake.mit.edu) and [ArduPilot](https://ardupilot.org). diff --git a/src/lib.rs b/src/lib.rs index 272b80d..fe71ac7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,13 @@ -use std::{ +#![no_std] + +extern crate alloc; + +use alloc::{collections::VecDeque, rc::Rc}; +use core::{ cell::RefCell, - collections::{HashMap, VecDeque}, - rc::Rc, - task::Waker, + task::{Poll, Waker}, }; +use hashbrown::HashMap; use task::{Scope, Task}; pub mod task; @@ -75,10 +79,10 @@ impl System { is_ready = true; } if is_ready { - std::task::Poll::Ready(()) + Poll::Ready(()) } else { queue.waker = Some(cx.waker().clone()); - std::task::Poll::Pending + Poll::Pending } }) .await diff --git a/src/task/context.rs b/src/task/context.rs index 4a8092c..42170a4 100644 --- a/src/task/context.rs +++ b/src/task/context.rs @@ -1,5 +1,6 @@ use super::Task; -use std::{any::TypeId, marker::PhantomData, rc::Rc}; +use alloc::rc::Rc; +use core::{any::TypeId, marker::PhantomData}; pub fn context() -> Context { Context { diff --git a/src/task/from_fn.rs b/src/task/from_fn.rs index f7353bc..6942c23 100644 --- a/src/task/from_fn.rs +++ b/src/task/from_fn.rs @@ -1,5 +1,5 @@ use super::Task; -use std::marker::PhantomData; +use core::marker::PhantomData; pub fn from_fn(f: F) -> FromFn where diff --git a/src/task/mod.rs b/src/task/mod.rs index e81a971..fe64b36 100644 --- a/src/task/mod.rs +++ b/src/task/mod.rs @@ -1,7 +1,7 @@ -use std::any::{Any, TypeId}; -use std::cell::RefCell; -use std::collections::HashMap; -use std::rc::Rc; +use alloc::rc::Rc; +use core::any::{Any, TypeId}; +use core::cell::RefCell; +use hashbrown::HashMap; mod context; pub use self::context::{context, Context}; diff --git a/src/task/provider.rs b/src/task/provider.rs index 70faa20..ee7d2a3 100644 --- a/src/task/provider.rs +++ b/src/task/provider.rs @@ -1,5 +1,6 @@ use super::Task; -use std::{any::TypeId, rc::Rc}; +use alloc::rc::Rc; +use core::any::TypeId; pub fn provider(value: T) -> Provider { Provider { diff --git a/src/task/then.rs b/src/task/then.rs index 4b90e1b..0556943 100644 --- a/src/task/then.rs +++ b/src/task/then.rs @@ -1,5 +1,5 @@ use super::{Scope, Task}; -use std::marker::PhantomData; +use core::marker::PhantomData; pub struct Then { task: T1,