[][src]Crate cala

Cala

Cala Build Status cala on crates.io Discord
Website | GitHub | Changelog | Tutorials

Getting Started

Each hardware interface can be enabled with a feature. For example, If you want to use the draw module and the screen module, you might put this in your Cargo.toml:

[dependencies.cala]
version = "0.8"
features = ["draw", "screen"]

Here's the boilerplate for your main.rs (you probably want to put modules in separate files):

use std::cell::RefCell;
// When no features are enabled, only imports prelude traits.
use cala::*;

enum State {
    A(RefCell<a::State>), // The only state
}

async fn event_loop(state: &mut State) {
    use State::*;
    match state {
        A(state) => a::State::event_loop(state).await,
    }
}

// Entry point
exec!(exec); // Set entry point for the app.
async fn exec() {
    let mut state = State::A(RefCell::new(a::State::new()));
    loop { event_loop(&mut state).await }
}

mod a {
    //! State A's structure and event loop.
    use std::cell::RefCell;
    use cala::*;

    // Data associated with state A.
    pub(super) struct State { }

    impl State {
        pub(super) fn new() -> Self {
            State { }
        }

        async fn dummy(state: &RefCell<Self>) {
        }

        // State A's event loop
        pub(super) async fn event_loop(state: &RefCell<Self>) {
            // Leaving this empty will result in the async
            // executor going to sleep.
            [Self::dummy(state).fut()].select().await;
        }
    }
}

Module documentation may include simple tutorials. More in depth tutorials may be found here.

Modules

accel

feature:accel - Hardware-acceleration (SIMD, etc.) (WIP)

bluetooth

feature:bluetooth - Bluetooth(WIP) and Bluetooth Low Energy(WIP) communication.

camera

feature:camera - Acess to webcam, selfie-camera, front-facing camera, etc. (WIP)

draw

feature:draw - Render (draw) graphics using the GPU and/or SIMD.

exec

feature:exec - Single / multi-processor execution of tasks / threads.

file

feature:file - Save and load data to the storage drive.

gpio

feature:gpio - General purpose I/O (WIP)

input

feature:input - Get user input.

journal

feature:journal - Text output through some medium (stdout, web console, serial, etc.)

microphone

feature:microphone - Audio capture (recording) device

net

feature:net - TCP and UDP(WIP) network communication.

pixels

feature:pixels - Display graphics onto the screen, usually via a window.

speaker

feature:speaker - Audio playback device

time

feature:time - API for getting the date and time of day.

user

feature:user - Retrieve user information.

Macros

exec

feature:exec - Set an asynchronous function as the entry point for the application.

Traits

Canvas

feature:draw - Something that can be drawn on.

IntoDynFut

feature:exec - Trait for converting Futures into an abstraction of pinned trait objects.

JoinFut

feature:exec - Trait for joining a tuple of futures into a single future.

Pixel

feature:draw - Pixel channel, color model, alpha and gamma mode.

PixelBlend

feature:draw - Blending operation for compositing.

SelectFut

feature:exec - A trait to select on a slice of Futures or Option<Future>s.

SpawnBlocking

feature:exec - Trait for spawning tasks in a thread pool to run closures as a Future.