From 281b591bebac884d887291ed25092cd3da61ea86 Mon Sep 17 00:00:00 2001 From: Stuart Harris Date: Thu, 11 May 2023 13:25:12 +0100 Subject: [PATCH] docs and doctests --- crux_core/tests/typegen.rs | 6 ++---- crux_http/tests/with_shell.rs | 6 ++---- docs/src/getting_started/core.md | 13 ++++++++++++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/crux_core/tests/typegen.rs b/crux_core/tests/typegen.rs index 1d4a10775..2407c3a9c 100644 --- a/crux_core/tests/typegen.rs +++ b/crux_core/tests/typegen.rs @@ -32,8 +32,8 @@ mod shared { } mod test { - use super::shared::{App, EffectFfi, Event}; - use crux_core::{bridge::Request, typegen::TypeGen}; + use super::shared::{App, Event}; + use crux_core::typegen::TypeGen; use uuid::Uuid; // FIXME this test is quite slow @@ -41,8 +41,6 @@ mod test { fn generate_types() { let mut gen = TypeGen::new(); - gen.register_type::>().unwrap(); - let sample_events = vec![Event::SendUuid(Uuid::new_v4())]; gen.register_type_with_samples(sample_events).unwrap(); diff --git a/crux_http/tests/with_shell.rs b/crux_http/tests/with_shell.rs index 2a0ac3e7f..0e303d3ce 100644 --- a/crux_http/tests/with_shell.rs +++ b/crux_http/tests/with_shell.rs @@ -134,11 +134,11 @@ mod shell { mod tests { use crate::{ - shared::{App, Effect, EffectFfi, Event}, + shared::{App, Effect, Event}, shell::run, }; use anyhow::Result; - use crux_core::{bridge::Request, typegen::TypeGen, Core}; + use crux_core::{typegen::TypeGen, Core}; use crux_http::protocol::HttpRequest; #[test] @@ -187,8 +187,6 @@ mod tests { fn generate_types() { let mut gen = TypeGen::new(); - gen.register_type::>().unwrap(); - gen.register_app::().unwrap(); let registry = match gen.state { diff --git a/docs/src/getting_started/core.md b/docs/src/getting_started/core.md index 4dbfd50cb..16af3efac 100644 --- a/docs/src/getting_started/core.md +++ b/docs/src/getting_started/core.md @@ -120,12 +120,23 @@ This crate serves as the container for type generation for the foreign languages - Copy over the [shared_types](https://github.com/redbadger/crux/tree/master/examples/counter/shared_types) folder from the counter example. -- Edit the `build.rs` file and make sure that your app type is registered. You may also need to register any nested enum types (due to a current limitation with the reflection library, see ). Here is an example of this from the [`build.rs`](https://github.com/redbadger/crux/blob/master/examples/notes/shared_types/build.rs) file in the `shared_types` crate of the `notes` example: +- Edit the `build.rs` file and make sure that your app type is registered. You may also need to register any nested enum types (due to a current limitation with the reflection library, see ). Here is an example of this from the [`build.rs`](https://github.com/redbadger/crux/blob/master/examples/notes/shared_types/build.rs) file in the `shared_types` crate of the [notes example](https://github.com/redbadger/crux/tree/master/examples/notes): ```rust {{#include ../../../examples/notes/shared_types/build.rs}} ``` +```admonish note +For the above to compile, your `Capabilities` struct must implement the `Export` trait. There is a derive macro that can do this for you, e.g.: + + #[derive(crux_macros::Effect, crux_macros::Export)] + pub struct Capabilities { + pub render: Render, + pub http: Http, + } + +``` + - Make sure everything builds and foreign types get generated into the `generated` folder. ```sh