Crate cala

Source
Expand description

Cala

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

§Getting Started

Each module needs to be enabled with a feature. For example, if you want to use the task module, put this in your Cargo.toml:

[dependencies.cala]
version = "0.8"
features = ["task"]

Here’s the boilerplate for your main.rs:

use cala::task::{exec, wait, never};

/// The program's shared state.
struct State {}

/// Event handled by the event loop.
enum Event {
    Never(()),
}

impl State {
    /// Event loop.
    fn event(&mut self, event: Event) {
        match event {
            Event::Never(_) => unreachable!(),
        }
    }
}

/// Start the async executor.
fn main() {
    let mut state = State {};
    let mut never = never();

    exec!(state.event(wait! {
        Event::Never((&mut never).await),
    }));
}

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

§A Tour of Cala

The rest of this crate documentation is dedicated to pointing out notable features of the Cala crate.

§Containers and Collections

The audio and video modules contain multimedia types for working with sounds and graphics.

§Platform Abstractions

The task module contains abstractions for dealing with asynchronous code.

The gui module contains abstractions for making a GUI (Graphical User Interface).

§I/O

Cala’s main purpose is to abstract over differences in common platforms, notably Windows, Web, and Unix derivatives (including mobile) for things that the standard library does not. This is mostly with multi-media I/O, defined in these modules:

  • bluetooth - bluetooth
  • camera - webcam, phone camera
  • client - client network communication
  • database - database for persistent storage
  • graphics - hardware-accelerated graphics rendering
  • haptic - haptic force feedback
  • info - system environment information
  • input - user input.
  • log - message logging
  • microphone - microphone input
  • port - general purpose I/O ports
  • random - random number generators
  • server - server network communication
  • speakers - speaker output
  • timer - using timers
  • usb - universal serial bus communcations
  • when - getting the current time
  • window - display graphics in an area on a screen.

Modules§

audio
Audio types.
bluetooth
Bluetooth and Bluetooth Low Energy communication. (WIP)
camera
Acess to webcam, selfie-camera, front-facing camera, etc. (WIP)
client
Client fetch API. (WIP)
database
Save and load data to persistent storage.
graphics
Render (draw) graphics using the GPU and/or SIMD.
gui
Create, layout and draw widgets (WIP)
haptic
Haptic force feedback.
info
Retrieve environment information.
input
User Input.
log
Text output through some medium (stdout, web console, serial, etc.)
microphone
Audio capture (recording) device
port
General purpose I/O (WIP)
random
Generate random numbers.
server
Server API. (WIP)
speakers
Audio playback device
task
Execution of asynchronous tasks.
timer
Asynchronous timers (WIP)
usb
Serial communication.
video
Video types.
when
API for getting the date and time of day.
window
Display graphics onto the screen, usually via a window.

Macros§

glue
Insert glue code so that your application can run on WASM and Android.