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§
- app
- Application related items
- color
- Color-related items
- drawing
- 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
- Geometry-related items.
- input
- Input-related items.
- input_
ext - Extension items related to input.
- render
- Render-related items.
- scene
- UI item abstraction
Macros§
- derive_
handle_ message - Macro to implement a handle message trait method that delegates known types to other methods on the struct implementing ViewAssistant.
- derive_
handle_ message_ with_ default - Macro to implement a handle message trait method that delegates known types to other methods on the struct implementing ViewAssistant.
Structs§
- View
Assistant Context - parameter struct passed to setup and update trait methods.
- ViewKey
- Key identifying a view.
Traits§
- View
Assistant - Trait that allows Carnelian developers to customize the behavior of views.
Functions§
- make_
message - Make a message
Type Aliases§
- Message
- Message type
- View
Assistant Ptr - 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.