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§
- Interact with the eth provider module.
- Interact with the system homepage.
- Interact with the HTTP server and client modules. Contains types from the
httpcrate to use as well. - 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.
- Interact with kimap, the onchain namespace
- Interact with the key_value module
- Interact with the networking module For configuration, debugging, and creating signatures with networking key.
- A set of types and macros for writing “script” processes.
- Interact with the sqlite module
- Interact with the timer runtime module.
- Interact with the virtual filesystem
Macros§
- 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. - Uses the
print_to_terminalfunction 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_terminalfunction directly. - Override the println! macro to print to the terminal. Uses the
print_to_terminalfunction 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_terminalfunction directly. - A macro for writing a “script” process. Using this will create the initial entry point for your process, including the standard
initfunction which is called by the system, and a set of calls that: - A macro for writing a process that serves a widget and completes. This process should be identified in your package
manifest.jsonwithon_exitset toNone.
Structs§
- Request builder. Use
Request::new()orRequest::to()to start a request, then build it, then callRequest::send()on it to fire. - Response builder. Use
Response::new()to start a response, then build it, then callResponse::send()on it to fire.
Enums§
- Error type for parsing an
Addressfrom a string. - The basic message type. A message is either a request or a response. Best practice when handling a message is to do this:
Functions§
- 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. - Get the next message body from the message queue, or propagate the error.
- See if we have the capability to message a certain process. Note if you have not saved the capability, you will not be able to message the other process.
- Get a capability in our store
- Fetch the blob of the most recent message we’ve received. Returns
Noneif that message had no blob. If it does have one, attempt to deserialize it from bytes with the provided function. - Fetch the persisted state blob associated with this process. This blob is saved using the
set_statefunction. ReturnsNoneif this process has no saved state. If it does, attempt to deserialize it from bytes with the provided function. - Create a blob with no MIME type and a generic type, plus a serializer function that turns that type into bytes.
- 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).