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 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 the key_value module
  • 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.
  • 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.

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.
  • 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 NOTE unfortunatly this is O(n), not sure if wit let’s us do any better
  • 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.
  • Simple wrapper over spawn() in WIT to make use of our good types