Crate grafos_std

Crate grafos_std 

Source
Expand description

grafos-std — The Rust SDK for programs targeting grafOS.

This crate provides typed, safe access to fabric resources (memory, block storage, GPU, CPU) through host function bindings. Programs compile against grafos-std and run as WASM tasklets on the grafOS runtime, or natively for development and testing.

§Resource modules

ModuleResourceHost APIStatus
memByte-addressable memoryFBMUImplemented
block512-byte block storageFBBUImplemented
gpuGPU kernel dispatchGPU_SUBMIT (0x0600)Implemented
cpuCPU tasklet dispatchTASKLET_SUBMIT (0x0500)Implemented

Each resource module exposes three types:

  • A handle (FabricMem, FabricBlock, etc.) for performing I/O.
  • A lease (MemLease, BlockLease, etc.) that wraps the handle with RAII cleanup.
  • A builder (MemBuilder, BlockBuilder, etc.) for requesting a resource with capacity constraints.

The fabric module provides a top-level entry point for discovery and allocation across all resource types.

§Dual-target design

On wasm32 targets, host functions link to real imports provided by the grafOS runtime. On native targets, the host module provides mock implementations backed by thread-local storage, so all resource modules work in unit tests without a WASM runtime.

§Feature flags

FeatureDefaultEffect
stdYesEnables std::error::Error impl for FabricError
serdeNoEnables serde_support module for typed struct I/O via postcard

§Quick start

use grafos_std::prelude::*;

fn main() -> grafos_std::Result<()> {
    let mem = grafos_std::mem::FabricMem::hello()?;
    mem.write(0, b"hello fabric")?;
    let data = mem.read(0, 12)?;
    assert_eq!(&data, b"hello fabric");
    Ok(())
}

Re-exports§

pub use error::FabricError;
pub use error::Result;

Modules§

affinity
Typed affinity constraints for lease builders (Phase 48.11).
block
Safe wrappers for FBBU (Fabric Bootstrap Binding Unit) host functions.
cpu
CPU tasklet resource module.
cpu_shared
Shared-memory tasklet SDK surface (Phase 48.3 P3 + P3.1).
error
Error types for fabric resource operations.
fabric
Discovery and allocation entry point for fabric resources.
gpu
GPU resource module.
grafos_worker_v0
grafos_worker_v0 — guest-facing WASM ABI for shared-memory tasklets.
host
Raw host function bindings for FBMU and FBBU.
lease
Shared lease lifecycle primitives used by resource modules.
mem
Safe wrappers for FBMU (Fabric Bootstrap Memory Unit) host functions.
net
Network resource module.
prelude
Convenience re-exports for use grafos_std::prelude::*.
serde_support
Serde integration for typed read/write of Rust structs to fabric memory.