astrid_sys/lib.rs
1//! Raw FFI bindings for the Astrid OS System API (The Airlocks).
2//!
3//! This crate defines the absolute lowest-level, mathematically pure ABI.
4//! Every single parameter and return type across the WASM boundary is
5//! represented as raw bytes (`Vec<u8>`).
6//!
7//! This provides true OS-level primitiveness: file paths can contain non-UTF-8
8//! sequences, IPC topics can be binary hashes, and the Kernel never wastes CPU
9//! validating string encodings. All ergonomic serialization is handled entirely
10//! by the `astrid-sdk` User-Space layer.
11
12#![allow(unsafe_code)]
13#![allow(missing_docs)]
14#![deny(clippy::all)]
15#![warn(unreachable_pub)]
16#![deny(clippy::unwrap_used)]
17#![cfg_attr(test, allow(clippy::unwrap_used))]
18
19use extism_pdk::*;
20
21#[host_fn]
22extern "ExtismHost" {
23 // -----------------------------------------------------------------------
24 // File System (VFS) Operations
25 // -----------------------------------------------------------------------
26 /// Check if a VFS path exists.
27 pub fn astrid_fs_exists(path: Vec<u8>) -> Vec<u8>;
28 /// Create a directory in the VFS.
29 pub fn astrid_fs_mkdir(path: Vec<u8>);
30 /// Read a directory in the VFS.
31 pub fn astrid_fs_readdir(path: Vec<u8>) -> Vec<u8>;
32 /// Get stats for a VFS path.
33 pub fn astrid_fs_stat(path: Vec<u8>) -> Vec<u8>;
34 /// Delete a file or directory in the VFS.
35 pub fn astrid_fs_unlink(path: Vec<u8>);
36
37 /// Read a file's contents from the VFS.
38 pub fn astrid_read_file(path: Vec<u8>) -> Vec<u8>;
39 /// Write contents to a file in the VFS.
40 pub fn astrid_write_file(path: Vec<u8>, content: Vec<u8>);
41
42 // -----------------------------------------------------------------------
43 // Inter-Process Communication (Message Bus & Uplinks)
44 // -----------------------------------------------------------------------
45 /// Publish a message to the OS event bus.
46 pub fn astrid_ipc_publish(topic: Vec<u8>, payload: Vec<u8>);
47 /// Subscribe to a topic on the OS event bus.
48 pub fn astrid_ipc_subscribe(topic: Vec<u8>) -> Vec<u8>;
49 /// Unsubscribe from the OS event bus.
50 pub fn astrid_ipc_unsubscribe(handle: Vec<u8>);
51 /// Poll for the next message on an IPC subscription handle.
52 pub fn astrid_ipc_poll(handle: Vec<u8>) -> Vec<u8>;
53
54 /// Register a direct uplink (frontend).
55 pub fn astrid_uplink_register(name: Vec<u8>, platform: Vec<u8>, profile: Vec<u8>) -> Vec<u8>;
56 /// Send a message via a direct uplink.
57 pub fn astrid_uplink_send(
58 uplink_id: Vec<u8>,
59 platform_user_id: Vec<u8>,
60 content: Vec<u8>,
61 ) -> Vec<u8>;
62
63 // -----------------------------------------------------------------------
64 // Storage & Configuration
65 // -----------------------------------------------------------------------
66 /// Get a value from the KV store.
67 pub fn astrid_kv_get(key: Vec<u8>) -> Vec<u8>;
68 /// Set a value in the KV store.
69 pub fn astrid_kv_set(key: Vec<u8>, value: Vec<u8>);
70
71 /// Get a system configuration string.
72 pub fn astrid_get_config(key: Vec<u8>) -> Vec<u8>;
73
74 // -----------------------------------------------------------------------
75 // General System (Network, Logging, & Scheduling)
76 // -----------------------------------------------------------------------
77 /// Issue an HTTP request.
78 pub fn astrid_http_request(request_bytes: Vec<u8>) -> Vec<u8>;
79 /// Log a message to the OS journal.
80 pub fn astrid_log(level: Vec<u8>, message: Vec<u8>);
81 /// Schedule a dynamic cron job to trigger the capsule later.
82 pub fn astrid_cron_schedule(name: Vec<u8>, schedule: Vec<u8>, payload: Vec<u8>);
83 /// Cancel a dynamic cron job.
84 pub fn astrid_cron_cancel(name: Vec<u8>);
85}