Expand description
Kinode process standard library for Rust compiled to Wasm
Must be used in context of bindings generated by kinode.wit
.
This library provides a set of functions for interacting with the kinode kernel interface, which is a WIT file. The types generated by this file are available in processes via the wit_bindgen macro, if a process needs to use them directly. However, the most convenient way to do most things will be via this library.
We define wrappers over the wit bindings to make them easier to use. This library encourages the use of IPC body and metadata types serialized and deserialized to JSON, which is not optimal for performance, but useful for applications that want to maximize composability and introspectability. For blobs, we recommend bincode to serialize and deserialize to bytes.
Re-exports§
pub use types::address::Address;
pub use types::capability::Capability;
pub use types::lazy_load_blob::LazyLoadBlob;
pub use types::package_id::PackageId;
pub use types::process_id::ProcessId;
pub use crate::kinode::process::standard::*;
Modules§
- eth
- Interact with the eth provider module.
- homepage
- Interact with the system homepage.
- http
- Interact with the HTTP server and client modules.
Contains types from the
http
crate to use as well. - kernel_
types - The types that the kernel itself uses – warning – these will be incompatible with WIT types in some cases, leading to annoying errors. Use only to interact with the kernel or runtime in certain ways.
- kimap
- Interact with kimap, the onchain namespace
- kinode
- kv
- Interact with the key_value module
- net
- Interact with the networking module For configuration, debugging, and creating signatures with networking key.
- scripting
- A set of types and macros for writing “script” processes.
- sqlite
- Interact with the sqlite module
- timer
- Interact with the timer runtime module.
- vfs
- Interact with the virtual filesystem
Macros§
- Spawn
- The
Spawn!()
macro is defined here as a no-op. However, in practice,kit build
will rewrite it during pre-processing. - call_
init - Implement the wit-bindgen specific code that the kernel uses to hook into
a process. Write an
init(our: Address)
function and call it with this. - kiprintln
- Uses the
print_to_terminal
function from the WIT interface on maximally-verbose mode, i.e., this print will always show up in the terminal. To control the verbosity, use theprint_to_terminal
function directly. - println
- Override the
println!
macro to print to the terminal. Uses theprint_to_terminal
function from the WIT interface on maximally-verbose mode, i.e., this print will always show up in the terminal. To control the verbosity, use theprint_to_terminal
function directly. - process_
println - Uses the
print_to_terminal
function from the WIT interface on maximally-verbose mode, i.e., this print will always show up in the terminal. To control the verbosity, use theprint_to_terminal
function directly. - script
- A macro for writing a “script” process. Using this will create the initial
entry point for your process, including the standard
init
function which is called by the system, and a set of calls that: - validate_
spawn_ args - widget
- A macro for writing a process that serves a widget and completes.
This process should be identified in your package
manifest.json
withon_exit
set toNone
.
Structs§
- Request
Request
builder. UseRequest::new()
orRequest::to()
to start a request, then build it, then callRequest::send()
on it to fire.- Response
Response
builder. UseResponse::new()
to start aResponse
, then build it, then callResponse::send()
on it to fire.- Send
Error
Enums§
- Address
Parse Error - Error type for parsing an
Address
from a string. - Message
- The basic
Message
type. AMessage
is either acrate::Request
or acrate::Response
. Best practices when handling aMessage
: - OnExit
- Process
IdParse Error - Send
Error Kind
Functions§
- _wit_
message_ to_ message - _wit_
send_ error_ to_ send_ error - await_
message - Await the next message sent to this process. The runtime will handle the
queueing of incoming messages, and calling this function will provide the next one.
Interwoven with incoming messages are errors from the network. If your process
attempts to send a message to another node, that message may bounce back with
a
SendError
. Those should be handled here. - await_
next_ message_ body - Get the next message body from the message queue, or propagate the error.
- can_
message - See if we have the
Capability
to message a certain process. Note if you have not saved theCapability
, you will not be able to message the other process. - get_
capability - Get a
Capability
in our store - get_
typed_ blob - Fetch the blob of the most recent message we’ve received. Returns
None
if that message had no blob. If it does have one, attempt to deserialize it from bytes with the provided function. - get_
typed_ state - Fetch the persisted state blob associated with this process. This blob is saved
using the
set_state()
function. ReturnsNone
if this process has no saved state. If it does, attempt to deserialize it from bytes with the provided function. - make_
blob - Create a blob with no MIME type and a generic type, plus a serializer function that turns that type into bytes.
- spawn
- Spawn a new process. This function is a wrapper around the standard
spawn()
function provided inkinode::process::standard
(which is generated by the WIT file).