
nyno-http-get and nyno-http-post and nyno-html-to-markdown${prev} instead of a object. The full object is often still available in ${prev_meta} (new convention).A simple example of a Rust plugin looks like this (core extension source code):
use rmpv::Value;
use plugin_sdk::{NynoPlugin, export_plugin};
#[derive(Default)]
pub struct NynoPrimes;
impl NynoPlugin for NynoPrimes {
fn run(&self, args: Value, context: &mut Value) -> i32 {
// Get limit from args[0]
let limit = match args {
Value::Array(v) if !v.is_empty() => v[0].as_i64().unwrap_or(0),
_ => 0,
};
if limit < 2 {
if let Value::Map(map) = context {
map.push((
Value::String("prev_error".into()),
Value::String("invalid input".into()),
));
}
return 1;
}
let mut primes = Vec::new();
for n in 2..=limit {
let mut prime = true;
for i in 2..=((n as f64).sqrt() as i64) {
if n % i == 0 {
prime = false;
break;
}
}
if prime {
primes.push(Value::Integer(n.into()));
}
}
if let Value::Map(map) = context {
map.push((
Value::String("prev".into()),
Value::Array(primes),
));
}
0
}
}
export_plugin!(NynoPrimes);