Crate kinode_process_lib

source
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§

Modules§

  • Interact with the eth provider module.
  • Interact with the system homepage.
  • Interact with the HTTP server and client modules. Contains types from the http crate 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_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 the print_to_terminal function directly.
  • Override the println! macro to print to the terminal. 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 the print_to_terminal function directly.
  • 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:
  • A macro for writing a process that serves a widget and completes. This process should be identified in your package manifest.json with on_exit set to None.

Structs§

Enums§

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 None if 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_state function. Returns None if 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 in kinode::process::standard (which is generated by the WIT file).