Skip to main content

Crate weirdnet_plugin

Crate weirdnet_plugin 

Source
Expand description

§weirdnet-plugin

The SDK for Weirdnet code spaces. A code space is compiled into a shared library that its host application loads and runs; this crate is the safe side of that: the Host API (load, update and create records, create models), Frames of loaded records, result Views, and the plugin! macro that exports the C ABI (abi).

ⓘ
use weirdnet_plugin::prelude::*;

pub fn run(host: &Host) -> Result<View> {
    let bars = host.input()?;                       // the code space's load request
    let close = bars.f64("close")?;
    let sma = series::sma(&close, &[20.0]);
    Ok(View::chart("close and SMA 20").x("timestamp", bars.f64("timestamp")?, true)
        .line("close", close).line("sma20", sma))
}
weirdnet_plugin::plugin!(run);

A host built on weirdnet-code-spaces writes this crate next to every code space it builds, and can write a copy for plugins built elsewhere. Which host methods exist (and what they read and write) is the host’s: Host::methods lists them.

Re-exports§

pub use json::Json;

Modules§

abi
The Weirdnet plugin C ABI, version 2. Shared verbatim by hosts and plugins.
columns
Computed columns to a result view (and writes): what generated code spaces (math, Polars, Python) end with, and handy in Rust ones.
connector
The ingest-connector host methods (a code space of kind ingest-connector; see docs/connectors.md). A connector gathers data, stores it raw (Host::store_raw), pipes it into its model (Host::pipe) and runs its rule set (Host::run_ruleset). Only main calls these, and only in a connector run: the host’s scheduler or a dry run, which records the calls instead of storing, piping or running rules.
json
A small JSON value with a parser and a writer: what the host and plugins exchange.
prelude
series
Vector math over columns: what math code spaces compile to, and handy in Rust ones. Missing values are NaN; windows that are not full yet give NaN.

Macros§

plugin
Export the plugin ABI for a fn(&Host) -> Result<View> (and the language it came from).

Structs§

Error
An error for the host to show.
FieldInfo
One field of a frame.
Frame
Loaded records, by column.
Group
Rows start .. start + len share the group key.
Host
The host for one run.
Load
A load request: which model, and which records in what order.

Enums§

View
What a run shows: a table, a chart, text, or tiles of those. A host may show tables as list tiles and charts as chart tiles, side by side for tiles.

Constants§

SDK_VERSION
The SDK version (the ABI version is abi::ABI_VERSION).

Type Aliases§

Result