Expand description
Carnelian
Carnelian is a prototype framework for writing Fuchsia applications in Rust.
Below is a tiny example of a Carnelian app.
The ViewAssistant
trait is a good place to start when learning
about Carnelian.
use anyhow::Error;
use carnelian::{
make_app_assistant,
render::{self},
App, AppAssistant, ViewAssistant, ViewAssistantContext, ViewAssistantPtr, ViewKey,
};
use zx::Event;
#[derive(Default)]
struct SampleAppAssistant;
impl AppAssistant for SampleAppAssistant {
fn setup(&mut self) -> Result<(), Error> {
Ok(())
}
fn create_view_assistant(&mut self, _: ViewKey) -> Result<ViewAssistantPtr, Error> {
SampleViewAssistant::new()
}
}
struct SampleViewAssistant;
impl SampleViewAssistant {
fn new() -> Result<ViewAssistantPtr, Error> {
Ok(Box::new(Self {}))
}
}
impl ViewAssistant for SampleViewAssistant {
fn render(
&mut self,
_render_context: &mut render::Context,
_buffer_ready_event: Event,
_view_context: &ViewAssistantContext,
) -> Result<(), Error> {
Ok(())
}
}
fn main() -> Result<(), Error> {
App::run(make_app_assistant::<SampleAppAssistant>())
}
Re-exports§
pub use crate::app::make_app_assistant;
pub use crate::app::App;
pub use crate::app::AppAssistant;
pub use crate::app::AppAssistantPtr;
pub use crate::app::AppSender;
pub use crate::app::AssistantCreator;
pub use crate::app::AssistantCreatorFunc;
pub use crate::app::LocalBoxFuture;
pub use crate::app::MessageTarget;
pub use crate::geometry::Coord;
pub use crate::geometry::IntCoord;
pub use crate::geometry::IntPoint;
pub use crate::geometry::IntRect;
pub use crate::geometry::IntSize;
pub use crate::geometry::Point;
pub use crate::geometry::Rect;
pub use crate::geometry::Size;
Modules§
- Application related items
- Color-related items
- Drawing-related items Functions for drawing in Carnelian Carnelian uses the Render abstraction over Forma and Spinel to put pixels on screen. The items in this module are higher- level drawing primitives.
- Geometry-related items.
- Input-related items.
- Extension items related to input.
- Render-related items.
- UI item abstraction
Macros§
- Macro to implement a handle message trait method that delegates known types to other methods on the struct implementing ViewAssistant.
- Macro to implement a handle message trait method that delegates known types to other methods on the struct implementing ViewAssistant.
Structs§
- parameter struct passed to setup and update trait methods.
- Key identifying a view.
Traits§
- Trait that allows Carnelian developers to customize the behavior of views.
Functions§
- Make a message
Type Aliases§
- Message type
- Reference to a view assistant. This type is likely to change in the future so using this type alias might make for easier forward migration.