33 releases (21 stable)

Uses new Rust 2024

new 1.8.0 Apr 11, 2025
1.7.1 Feb 3, 2025
1.7.0 Nov 26, 2024
1.4.2 Jul 2, 2024
0.0.1 Jul 6, 2021

#38 in #no-mangle

Download history 402/week @ 2024-12-21 50/week @ 2024-12-28 258/week @ 2025-01-04 541/week @ 2025-01-11 409/week @ 2025-01-18 356/week @ 2025-01-25 630/week @ 2025-02-01 549/week @ 2025-02-08 449/week @ 2025-02-15 569/week @ 2025-02-22 564/week @ 2025-03-01 476/week @ 2025-03-08 495/week @ 2025-03-15 538/week @ 2025-03-22 648/week @ 2025-03-29 677/week @ 2025-04-05

2,429 downloads per month
Used in 15 crates (via gstd)

GPL-3.0 license

195KB
3K SLoC

gcore

Core library for Gear programs.

Features

codec - Allows you to get actual errors occurred instead of ExtError::Some one.


lib.rs:

Lightweight library for use in Gear programs.

This library should be used as a standard library when writing Gear programs. Compared to gstd crate, this library provides lower-level primitives that allow you to develop less expensive programs. Choose it if you are ready to write more code but get a more efficient Wasm.

Note that you are to define panic and out-of-memory handlers, as the crate does not provide them by default.

Examples

#![no_std]
#![feature(alloc_error_handler)]

extern crate galloc;

use gcore::msg;

#[unsafe(no_mangle)]
extern "C" fn handle() {
    let mut bytes = [0; 64];
    msg::read(&mut bytes).expect("Unable to read");
    if let Ok(payload) = core::str::from_utf8(&bytes) {
        if payload == "PING" {
            msg::reply(b"PONG", 0).expect("Unable to reply");
        }
    }
}

#[alloc_error_handler]
pub fn oom(_: core::alloc::Layout) -> ! {
    core::arch::wasm32::unreachable()
}

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! {
    core::arch::wasm32::unreachable()
}

Dependencies

~5MB
~106K SLoC